function showMenu(divid, action, count, index){
		if(action == 's') {
				document.getElementById(divid).style.display="block"; 
		}
		else {
			document.getElementById(divid).style.display="none";
		}
		for(var i=1; i <= count; i++) {
			if(i != index) {
				var div = "mm"+i;
				document.getElementById(div).style.display="none";
			}
		}
}

function openPopUp(page,width,height){ 
	var winOptions;
  
 	winOptions = "top=50, left=200, width="+width+", height="+height+", scrollbars=yes";

	window.open(page, '',winOptions+'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0',true);

}	
     
function getParameter(name,media) {    
 if(typeof window.location.parameters == "undefined") { 
	setupParameters(media); 
	}
  return window.location.parameters[name];
}	
function setupParameters(media) {  
	var str = ""; 
	var med = media;
	var did = "";
	var mid = "";
	var smid = "";
    var parameters = new Object();   
	

    if(window.location.search) {  
        var paramArray = window.location.search.substr(1).split("&");  
        var length = paramArray.length;  
		

	    for (var index = 0;index <length; index++ ) { 
            var param = paramArray[index].split("=");  
            var name = param[0];  
            var value =  typeof param[1] == "string" ? decodeURIComponent(param[1].replace(/\+/g, ' ')) : null; 
            parameters[name] = value; 

			if(parameters[name]){
				var element=name; 
				
				var estr =  parameters[name].split(",");    
				var str = estr[0];   
				if(element=="div"){ 
					did = str;  
				}
				if(element=="menu"){ 
					mid = str; 
				} 
				if(element=="smenu"){ 
					smid = str; 
				} 
				if(element=="media"){ 
					med = str; 
				} 
					
			}  
        }
	
 } 
	if(did!='' && mid!=''&& smid!=''){
		doShow(did,mid,smid);	
	} 
	if(did=='' && mid==''&& smid==''){
		doShow(med+"_1",med+"_1_m",med+"_1_m_1");	
	} 
	window.location.parameters = parameters; 
} 



function RightMenu(divid, a, count, index){
		if(a == 's') {
				document.getElementById(divid).style.display="block"; 
		}
		else {
			document.getElementById(divid).style.display="none";
		}
		for(var i=1; i <= count; i++) {
			if(i != index) {
				var div = "Prod"+i;
				document.getElementById(div).style.display="none";
			}
		}
}

function doShow(which,which_m,which_sm){ 

	total = document.frm.total.value;    
	media = document.frm.media.value;    
	
	var which_n = '',which_m_n = '',which_sm_n = '', i,k,j;
	
	document.getElementById(which).style.display= "block";
	document.getElementById(which_m).style.display= "block";
	document.getElementById(which_m).className = "active"; 
	document.getElementById(which_sm).className = "sactive";
	
	for(i=1;i<=total;i++){
		which_n = media+"_"+i;  
		//alert(which_n);
			if(which_n!=which){ //alert(which_n);
				 if(document.getElementById(which_n)==null){
					continue;
				}
				document.getElementById(which_n).style.display = "none"; 
					
			}
	}	 
	for(k=1;k<=total;k++){ 
		which_m_n = media+ "_"+k+"_m";
		
			if( which_m_n!=which_m){ // alert(which_m_n);
				 if(document.getElementById(which_m_n)==null){
					continue;
				}
				document.getElementById(which_m_n).className ="myClass";
			} 
	}
	
	for(j=1;j<=total;j++){ 
		which_sm_n = which_m+"_"+j;	
		
			if(which_sm_n!=which_sm){// alert(which_sm_n);
			 if(document.getElementById(which_sm_n)==null){
					continue;
				}
				document.getElementById(which_sm_n).className = "myClass"; 
			}
	}
	
	//  */
	
}

function getParameterN(name,media) {   

 if(typeof window.location.parameters == "undefined") {  
	setupParametersN(media); 
	}
  return window.location.parameters[name];
	//setupParametersN(media); 
}	
function setupParametersN(media) {  
	 
	var str = ""; 
	var med = media;
	var did = "";
	var mid = "";
	var smid = "";
	var pid = "";
	var imgSrc = "";
	var alt = "";
    var parameters = new Object();   
	

    if(window.location.search) {  
        var paramArray = window.location.search.substr(1).split("&");  
        var length = paramArray.length;  

	    for (var index = 0;index <length; index++ ) { 
            var param = paramArray[index].split("=");  
            var name = param[0];  
            var value =  typeof param[1] == "string" ? decodeURIComponent(param[1].replace(/\+/g, ' ')) : null; 
            parameters[name] = value; 
		

			if(parameters[name]){
				var element=name; 
				
				var estr =  parameters[name].split(",");    

				var str = estr[0];   
					
				if(element=="imgSrc"){ 
					imgSrc = str;  
				}
				if(element=="div"){ 
					did = str;  
				}
				if(element=="menu"){ 
					mid = str; 
				} 
				if(element=="smenu"){ 
					smid = str; 
				} 
				if(element=="media"){ 
					med = str; 
				} 
				if(element=="pageId"){ 
					pid = str; 
				} 
				if(element=="alt"){ 
					alt = str; 
				} 
					
			}  
        }
	
 } 
	if(imgSrc!='' && did!='' && mid!=''&& smid!='' && pid!=''&& alt!=''){
			
		doShowN(imgSrc,did,mid,smid,pid,alt);  
	}  
	if(imgSrc=='' || did=='' || mid==''|| smid=='' || pid=='' || alt=='' ){ 
		
		if(med=="prt")
		{
			medF="img/print/Alchemist/Alchemist-1";
			alt = "Alchemist";
		}
		if(med=="odr")
		{
			medF="img/outdoor/Alchemist/Alchemist-1";
			alt = "Alchemist";
		}
		if(med=="rad")
		{
			medF="img/radio/corral_holidays_1";
			alt = "Corral Holidays";
		}
		if(med=="tvc")
		{
			medF="img/tvc/cello1";
			alt = "Cello Pen";
		}
		if(med=="exb")
		{
			medF="img/Exhibition/Cello/Cello-1";
			alt = "Cello";
		}
		 
		doShowN(medF,med+"_1",med+"_1_m",med+"_1_m_1",med+"_1_p_1",alt); 
	} 
	window.location.parameters = parameters; 
} 



function doShowN(imgSrc,which,which_m,which_sm,which_p,altText){  

	total = document.frm.total.value;    
	media = document.frm.media.value;    
	//alert(imgSrc+","+which+","+which_m+","+which_sm+","+which_p+","+altText);
	//alert(imgSrc);
	var which_n = '',which_m_n = '',which_sm_n = '',which_pn = '', videoSrc='', i,k,j,l
		
		/*heavyImage = new Image(); 
		heavyImage.src = imgSrc+".jpg";	 
		alert(heavyImage.complete);
		if (!heavyImage.complete) {
			alert("dfd");
			document.getElementById("mainImage").src = "includes/images/loader.gif"; 
		}
		else if (heavyImage.complete) {
			alert("uuuuuuuuuu");
			document.getElementById("mainImage").src= imgSrc+".jpg"; 
		}*/
		
		document.getElementById("mainImage").src= imgSrc+".jpg";
		document.getElementById("mainImage").alt= altText;
		document.getElementById("mainImage").title= altText;
		
		videoSrc += "<div class=\"videoBordera\"><object type=\"application/x-shockwave-flash\" data=\"FlowPlayerLP.swf\" width=\"373\" height=\"323\">";
        videoSrc += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
        videoSrc += "<param name=\"movie\" value=\"FlowPlayerLP.swf\" />";
        videoSrc += "<param name=\"quality\" value=\"high\" />";
        videoSrc += "<param name=\"scale\" value=\"noScale\" />";
        videoSrc += "<param name=\"allowfullscreen\" value=\"true\" />";
        videoSrc += "<param name=\"wmode\" value=\"\" />";
        videoSrc += "<param name=\"pluginspage\" value=\"\" />";
        videoSrc += "<param name=\"flashvars\" value=\"config=\{";
		videoSrc += "videoFile: '"+imgSrc+".flv', ";
		videoSrc += "initialScale:'scale', ";
		videoSrc += "loop:'false',";
		videoSrc += "autoPlay:'true',";
		videoSrc += "splashImageFile:'"+imgSrc+".jpg',";
		videoSrc += "bufferLength:5, ";
		videoSrc += "progressBarColor1: 0xd9d9d9, ";
		videoSrc += "progressBarColor2: 0xee125a,";
		videoSrc += "bufferingAnimationColor: 0xee125a,";
		videoSrc += "menuItems:[true, true, true, true, true, false], ";
		videoSrc += "autoBuffering:'false', ";
		videoSrc += "showFullScreenButton:'true',";
		videoSrc += "useNativeFullScreen:'true'";
		videoSrc += "\}\" />";
        videoSrc += "</object></div>"; 
		
		document.getElementById("mainVid").innerHTML= videoSrc; 
		document.getElementById(which).style.display= "block";
		document.getElementById(which_m).style.display= "block";
		document.getElementById(which_m).className = "active"; 
		document.getElementById(which_sm).className = "sactive";
		document.getElementById(which_p).className = "active"; 	
	 
	
	for(i=1;i<=total;i++){
		which_n = media+"_"+i;   
			if(which_n!=which){ 
				 if(document.getElementById(which_n)==null){
					continue;
				}
				document.getElementById(which_n).style.display = "none"; 
					
			}
	}	 
	for(k=1;k<=total;k++){ 
		which_m_n = media+ "_"+k+"_m";
		
			if( which_m_n!=which_m){ // alert(which_m_n);
				 if(document.getElementById(which_m_n)==null){
					continue;
				}
				document.getElementById(which_m_n).className ="myClass";
			} 
	}
	
	for(j=1;j<=total;j++){ 
		which_sm_n = which_m+"_"+j;	
		
			if(which_sm_n!=which_sm){ //alert(which_sm_n);
			 if(document.getElementById(which_sm_n)==null){
					continue;
				}
				document.getElementById(which_sm_n).className = "myClass"; 
			}
	} 
	
	for(l=1;l<=total;l++){ 
		 which_pn = which+"_p_"+l;  
		 
		if(which_pn!=which_p){  
		
			 if(document.getElementById(which_pn)==null){
				continue;
			}
			document.getElementById(which_pn).className = "myClass"; 
				
		}
	}	 
	
	//  */
	
}
   
