/*  General JS functions
  	COPYRIGHT: This is the property of FotoDesk, and may not be distributed without our permission. 
	@author Vandhana
	@modifiedDate 03-02-2009
	@createdDate  03-02-2009   
*/
/**
 * Global variable to set action name, to use in trackIt(). 
 * This is set from header portion of decorator page.
 */
var action="home";
/**
 * Global variable to set country name, to use in trackIt(). 
 * This is set from header portion of decorator page.
 */
var country="eu";
/**
 * Global variable to set language name, to use in trackIt(). 
 * This is set from header portion of decorator page.
 */
var lang="en";
/**
 * JS function used for google tracking.
 * The function automatically appends country and language values, to the 
 * input parameter trackCode.
 * If the addActionName is true, it also appends the action name before trackCode.
 * Final format of google track code will be:
 * "/<country><language>/<action name>/<trackCode>
 * 
 * @param trackCode
 * @param addActionName
 */
function trackIt(code,addActionName) {
	var trackCode="/"+country+lang+"/"
	if(addActionName!=null && addActionName==true)
	    trackCode+=action+"/";
    trackCode+=code;
   // alert(trackCode);
    if(pageTracker!=null)
    	pageTracker._trackPageview(trackCode);
}
/**
 * Function to select country. 
 * @param ob
 * @return
 */
function changeCountry(ob) {
	if(ob.selectedIndex > 0)
	{
		var countryLan=ob.options[ob.selectedIndex].value;
		var frm=document.getElementsByName('countrySelectForm')[0];
		frm.country.value=countryLan.split("_")[0];
		frm.lang.value=countryLan.split("_")[1];
		frm.submit();
	}
}

function systemDetails() {
	var bname = navigator.appName
	var OSName = "Unknown OS";
	var element = document.getElementsByName("browserName");
	var element1 = document.getElementsByName("os");
	element[0].value = bname;

	if (navigator.appVersion.indexOf("Win") != -1)
		OSName = "Windows";
	if (navigator.appVersion.indexOf("Mac") != -1)
		OSName = "MacOS";
	if (navigator.appVersion.indexOf("X11") != -1)
		OSName = "UNIX";
	if (navigator.appVersion.indexOf("Linux") != -1)
		OSName = "Linux";
	element1[0].value = OSName;

}
//Script for homepage Browse Product component
	var boxProduct=1;
	var maxProduct=12;
function changeContent()
{
	if(boxProduct==maxProduct){
		document.getElementById(boxProduct).style.display='none';	
		boxProduct=0; 
	}
	if(boxProduct!=0){
		document.getElementById(boxProduct).style.display='none';
	}
		document.getElementById(boxProduct+1).style.display='block'; 	
		boxProduct++; 	
}
function changeContentRight()
{
	 
		document.getElementById(boxProduct).style.display='none'; 	
		boxProduct--;
	if(boxProduct!=0){	
		document.getElementById(boxProduct).style.display='block'; 	
	}else{
		document.getElementById(maxProduct).style.display='block'; 
		boxProduct=maxProduct;
	}
	
}


function getFlashVersion() {

	try {
		try {
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			try {
				
				axo.AllowScriptAccess = 'always';
			} catch (e) {
				return '6,0,0';
			}
		} catch (e) {
		}
		return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable(
				'$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
	} catch (e) {
		try {
			if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
				return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description
						.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
			}
		} catch (e) {
		}
	}
	return '0,0,0';
}

function flash() {
	
	var version = getFlashVersion().split(',').shift();
	var flash = document.getElementsByName("flashversion");
	flash[0].value = "Flash version " + version;
	
}
function hideDiv() {

	var i = document.getElementsByName("plus");
	if (i[0].src.indexOf("minus") != -1) {
		i[0].src = plusimg
		i[0].onclick = showDiv;
	}
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('hideShow').style.display = 'none';
	} else {
		if (document.layers) { // Netscape 4
			document.hideShow.display = 'none';
		} else { // IE 4
			document.all.hideShow.style.display = 'none';
		}
	}
}

function showDiv() {

	var i = document.getElementsByName("plus");
	var i1 = document.getElementsByName("feedbacktype");
	//i1[0].value = "hiHIHHHHHHH";
	
	var imgName;
	if (i[0].src.indexOf("plus") != -1) {
		i[0].src = minusimg
		i[0].onclick = hideDiv;
	}

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('hideShow').style.display = 'block';     		
	} else {
		if (document.layers) { // Netscape 4
			document.hideShow.display = 'block';
		} else { // IE 4
			document.all.hideShow.style.display = 'block';
		}
	}
}

function hideDiv1() {

	var i = document.getElementsByName("plu");
	if (i[0].src.indexOf("minus") != -1) {
		i[0].src = plusimg
		i[0].onclick = showDiv1;
	}
	if (document.getElementById) {
		document.getElementById('hideSystem').style.display = 'none';
	} else {
		if (document.layers) {
			document.hideSystem.display = 'none';
		} else { // IE 4
			document.all.hideSystem.style.display = 'none';
		}
	}
}

function showDiv1() {

	var i = document.getElementsByName("plu");
	var imgName;
	if (i[0].src.indexOf("plus") != -1) {
		i[0].src = minusimg
		i[0].onclick = hideDiv1;
	}

	if (document.getElementById) {
		document.getElementById('hideSystem').style.display = 'block';
	} else {
		if (document.layers) {
			document.hideSystem.display = 'block';
		} else {
			document.all.hideSystem.style.display = 'block';
		}
	}
}
/**
 * Method enables/disables the 'Phone number' and 'Mobile number'
 * fields in contact us page.
 * @return
 */
function updateCallBackFields() {
	var ob= document.getElementById('contact_feedbacktype');
	if(ob.selectedIndex==0 || ob.selectedIndex==1 || ob.selectedIndex==4)	{
		document.getElementById('contact_landnum').disabled  = false;	
		document.getElementById('contact_landnum').className = "registerColumns"; 
		document.getElementById('contact_mobilenum').disabled  = false;
		document.getElementById('contact_mobilenum').className = "registerColumns"; 
	}
	else
	{
		document.getElementById('contact_landnum').disabled  = true;
		document.getElementById('contact_landnum').className = "contactDisabled"; 
		document.getElementById('contact_mobilenum').disabled  = true;
		document.getElementById('contact_mobilenum').className = "contactDisabled"; 
	}
	for (var i=0; i<10; i++)
		
	{
		document.getElementById('feedback'+i).className="hide";
	}
	document.getElementById('feedback'+ob.selectedIndex).className="show";
}
var prodStartIndex=0;
function changeProductContent(obj){
	for (var i=prodStartIndex; i<12; i++)
	
	{
		if(document.getElementById('pro'+i)!=null)
			document.getElementById('pro'+i).className="hide";
		if(document.getElementById('proMenu'+i)!=null)
		{	
			document.getElementById('proMenu'+i).className="notSelected";
			document.getElementById("proMenu"+i).style.color="#FFFFFD";
		}	
	
	}
		
	document.getElementById('pro'+obj).className="show";
	document.getElementById("proMenu"+obj).className="selected";
	document.getElementById("proMenu"+obj).style.color="#000000";
	
	
}
/**
 * function to limit number of chars in text area
 * @param textarea
 * @param limit
 * @return
 */
function limitChars(textarea, limit){
	var text = textarea.value; 
	var textlength = text.length;
	if(textlength > limit)
	{
		textarea.value = text.substr(0,limit);
		return false;
	}
	else
	{
		return true;
	}

}
