// JavaScript Document
var check_process = 0;
var site_name = "Colors Workshop";
function checkProcessForm(){
	
	if(check_process == 0){
		check_process = 1;
	}else{
		
		result = document.process_form.document.body.innerHTML;
		
		newHTML = "<table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"color:#ffffff;\">\n";
		newHTML += "<tr style=\"font-size:20px;\"><td width=\"10\" style=\"border-top:1px solid #ffffff;border-bottom:1px solid #ffffff;\">&nbsp;</td><td style=\"border-top:1px solid #ffffff;border-bottom:1px solid #ffffff;\">Enquiry</td><td width=\"10\" style=\"border-top:1px solid #ffffff;border-bottom:1px solid #ffffff;\">&nbsp;</td></tr>\n";
		newHTML += "<tr ><td colspan=4 >&nbsp;</td></tr>\n"
		newHTML += "<tr ><td width=\"10\">&nbsp;</td><td >";
		
		
		
		if(result == "success=1"){
			
			newHTML += "Thank You. Your enquiry has been successfully submitted and one of our representatives will contact you shortly.<br><br>If you need further assistance please call <b>Freephone 0800 634 9984</b>";
			
		}else{
			
			newHTML += "Sorry there as been and error sending your enquiry. Please try again later or call <b>Freephone 0800 634 9984</b> for further assistance.";
			
		}
		
		newHTML += "</td><td width=\"10\" >&nbsp;</td></tr>\n"
		newHTML += "</table>\n";
		document.getElementById('form_id').innerHTML = newHTML;
	}
	
	
	
	
}



function openSurvey(survey){



		window.open(survey,"","width=100,height,100,left=0,top=0,location=no,toolbar=no,resizable=no,scrollbars=yes");

}

function openEnlarged(image,url,txt){

		dWidth = 700;
		dHeight = 595;
		dHeight_1 = 495;
		
		var imageopen = url+image;
		var winwidth = screen.width;
		var winheight = screen.height;
		var leftpos = (winwidth - dWidth)/2;
		var toppos = (winheight - dHeight)/2;
		
		
		if(navigator.appVersion.indexOf("Win") != -1){
			
			if(txt){
				h = dHeight;
			}else{
				h = dHeight_1;
			}
			
			en = window.open("","","width="+dWidth+",height="+h+", left="+leftpos+",top="+toppos+",scrollbars=no,toolbar=no,location=no");
			en.document.write("<html><head><title>Colors Workshop</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'></head><body bgcolor='#ffffff' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src='"+imageopen+"' width='"+dWidth+"' height='"+dHeight_1+"'>");
			if(txt){
				
					re=/\[new_line\]/gi
					txt = txt.replace(re,"\n");
				
					re=/\[double_quotes\]/gi
					txt = txt.replace(re,"\"");
					
					re=/\[single_quotes\]/gi
					txt = txt.replace(re,"'");
					
					en.document.write("<textarea style=\"width:100%;height:100px;border:1px solid #ffffff;background-color:#ffffff;color:#000000;font-size:14px;font-family: Arial, Helvetica, sans-serif;border-top:1px solid #000000\">"+txt+"</textarea>");
				
			}
			en.document.write("</body></html>\n");
		
		
		}else{
		
			en = window.open(imageopen,"","width="+dWidth+",height="+dHeight_1+", left="+leftpos+",top="+toppos+",scrollbars=no,toolbar=no,location=no");
		}

}




function setUpLink(){

expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6);
	
	if(document.cookie != ""){
			
			foundLink = 0;
			allCookies = document.cookie.split("; ");
			
			
			for(i=0;i<allCookies.length;i++){
				
				cookieName = allCookies[i].split("=")[0];
				cookieValue = allCookies[i].split("=")[1];
				
				if((cookieName == "displayedLinks_" + site_name)&&(cookieValue != null)){
					displayedLinks = cookieValue;
					displayedLinks = displayedLinks.split(",");
					
					foundLink = 1;
					break;
				}
				
			}
			
			
			if(foundLink == 0){
				
				displayedLinks = new Array();
				
			}else{
	
	
	
	
				if(displayedLinks.length  >0){

						for(i=0;i<displayedLinks.length;i++){
							
							thisLink = displayedLinks[i].split("; ")[0];
							
							
							
							if(document.getElementById(thisLink) != null ){
								
								thisMenu = document.getElementById(thisLink).style;
								thisMenu.display = "block";
							}else{
								
								displayedLinks.splice(i,1);
								document.cookie = "displayedLinks_"+site_name+"="+displayedLinks+";expires="+expireDate.toGMTString();
								
							}
				
						}
				
				}
		
			}
		
		
	}else{
	
	displayedLinks = new Array();
	
	
	
	}


}




function toggleLinks(links){
	
	expireDate = new Date
	expireDate.setMonth(expireDate.getMonth()+6);
	
	if(displayedLinks.length > 0){
	
		addLink = 1;
	
		for(i=0;i<displayedLinks.length;i++){
			
			if(document.getElementById(displayedLinks[i]) == null ){
				
				displayedLinks.splice(i,1);
				document.cookie = "displayedLinks_"+site_name+"="+displayedLinks+";expires="+expireDate.toGMTString();
				
			}
		
		
			if(displayedLinks[i] == links){
			
			thisMenu = document.getElementById(links).style;
			thisMenu.display = "none";
			displayedLinks.splice(i,1);
			if(displayedLinks.length > 0){
			
			document.cookie = "displayedLinks_"+site_name+"="+displayedLinks+";expires="+expireDate.toGMTString();
			}else{
			
				deleteCookie();
			}
			addLink = 0;
			break;
			}

		
		}
		
		if(addLink == 1){
		
			
			thisMenu = document.getElementById(links).style;
			thisMenu.display = "block";
			displayedLinks.push(links);
			document.cookie = "displayedLinks_"+site_name+"="+displayedLinks+";expires="+expireDate.toGMTString();
			
		}
		
	}else{
	
		thisMenu = document.getElementById(links).style;
		thisMenu.display = "block";
		displayedLinks.push(links);
		document.cookie = "displayedLinks_"+site_name+"="+displayedLinks+";expires="+expireDate.toGMTString();
	
	}

	


}

function deleteCookie(){
	


expireDate = new Date
expireDate = new Date
expireDate.setMonth(expireDate.getMonth()-6);
if(document.cookie != ""){
document.cookie = "displayedLinks_"+site_name+"=;expires="+expireDate.toGMTString();
displayedLinks = new Array();
}

}

function checkFAQ(){
		
	if(document.referrer != ""){	
	thisURL = document.referrer.split("?")[0];
		if(thisURL == "http://www.colorsworkshop.co.uk/scripts/memberPages.php"){
			deleteCookie();
			//setUpLink();
			
	
		}else{
			
			setUpLink();
		}
	}else{
		
		setUpLink();
	}
	
	
}

function checkResize(){
	
	
	
}


function checkSize(){
	
	var isIE4 = ((document.all) ? true : false);
	
	
	
	if(isIE4){
	
				
				document.getElementById('linksID').style.height = 100;
				p1 = document.getElementById('pageID').clientHeight;
				document.getElementById('linksID').style.height = p1 - 250;
				
	
	
	}
	
	
	

	
}




