
	function setCookie(name, value, expires) {
		var today = new Date(); 
   	today.setTime( today.getTime() ); 
		if ( expires ) 
  		{ expires = expires * 1000 * 60 * 60 * 24; } 
 			 var expires_date = new Date( today.getTime() + (expires) ); 
 			 var curCookie = name + "=" + escape(value) +	";expires=" + expires_date + "; path=/";
  			document.cookie = curCookie;
		}

function setCookieBetter(name, value, expires) {
	expire = new Date((new Date()).getTime() + expires * 3600000);
	var curCookie = name + "=" + escape(value) +	"; expires=" + expire.toGMTString() + "; path=/";
	document.cookie = curCookie;
}

  function getCookie(name) { // use: getCookie("name");
  			bikky = document.cookie;
  		  var index = bikky.indexOf(name + "=");
  		  if (index == -1) return null;
  		  index = bikky.indexOf("=", index) + 1;
  		  var endstr = bikky.indexOf(";", index);
  		  if (endstr == -1) endstr = bikky.length;
  		  return unescape(bikky.substring(index, endstr));
  		}
  
  

function bookmark(anchor){
	if(window.external){	
		window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
		return false;
	}
	return true;
}
	
function open_popup(uri, wdth, hght, lft, tp, nme)	{
	newwindow=window.open(uri,nme,'height='+hght+',width='+wdth+',left='+lft+',top='+tp+'');
	if (window.focus) {newwindow.focus()}
	return false;
}
						


function popitup(URL)	{
	newwindow=window.open(url,'popup_name','height=568,width=623');
	if (window.focus) {newwindow.focus()}
	return false;
}	

	
function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}	

function readCookie(name) {
	var cookieValue = "";
	var search = name + "=";
  	if(document.cookie.length > 0) { 
   		offset = document.cookie.indexOf(search);
	   	if (offset != -1)  { 
   			offset += search.length;
    		end = document.cookie.indexOf(";", offset);
	     	if (end == -1) end = document.cookie.length;
    			cookieValue = unescape(document.cookie.substring(offset, end))
	    }
	}
	return cookieValue;
}

function getScrollHeight(){
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

function getPageSize(){	
	var xScroll, yScroll;	
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}		
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight*3;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}


function hideDHTML(id)	{
	document.getElementById(id).style.visibility = 'hidden';		
	document.getElementById('overlay_' + id).style.width = 0 +"px";
	document.getElementById('overlay_' + id).style.height = 0 +"px";	
	document.getElementById('overlay_' + id).style.visibility='hidden';	
}


function gotoHomePage(){
	location.href='http://www.victorklassen.com/';
}

function gotoContact(){
	location.href='http://www.victorklassen.com/about-us.html';
}

var timerID = 0;
function show_menu(name,el){	
	clearTimeout(timerID);
	hideallmenu();
	if(el == 0)
		document.getElementById("hover_bar_item"+name).style.visibility = 'visible';
	else{
		document.getElementById("nav-item"+name).style.visibility = 'visible';
		document.getElementById("hover_bar_item"+name).style.visibility = 'visible';
		document.getElementById('item'+name+'-arrow').style.backgroundPosition ='-129px -172px';
	}
}

function timeHide(name,active){
	timerID = setTimeout("hidemenu('"+name+"','"+active+"')", 1000);
}

function hidemenu(name,active){
	document.getElementById("nav-item"+name).style.visibility = 'hidden';
	document.getElementById("hover_bar_item"+name).style.visibility = 'hidden';
	//document.getElementById('item'+name+'-arrow').src ='images/vk-menu-arrow.jpg';
if(document.getElementById('item'+name+'-arrow'))
		document.getElementById('item'+name+'-arrow').style.backgroundPosition ='-117px -172px';
	if(active != 0)
		document.getElementById("hover_bar_item"+active).style.visibility = 'visible';
}

function hideallmenu(){
//	document.getElementById("nav-furniture").style.visibility = 'hidden';	
//	document.getElementById("nav-architectural").style.visibility = 'hidden';	
//	document.getElementById("nav-accessories").style.visibility = 'hidden';
//	document.getElementById('furniture-arrow').src ='images/vk-menu-arrow.jpg';
//	document.getElementById("hover_bar_accessories").style.visibility = 'hidden';
//	document.getElementById('architectural-arrow').src ='images/vk-menu-arrow.jpg';
//	document.getElementById("hover_bar_architectural").style.visibility = 'hidden';	
//	document.getElementById('furniture-arrow').src ='images/vk-menu-arrow.jpg';
//	document.getElementById("hover_bar_furniture").style.visibility = 'hidden';
	for(i=1;i<=4;i++){
			document.getElementById("nav-item"+i).style.visibility = 'hidden';	
			document.getElementById("hover_bar_item"+i).style.visibility = 'hidden';
			//document.getElementById('item'+i+'-arrow').src ='images/vk-menu-arrow.jpg';
			if(document.getElementById('item'+i+'-arrow'))
				document.getElementById('item'+i+'-arrow').style.backgroundPosition ='-117px -172px';
	}
	
}
function findLeft(obj) {
	var curleft =  0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;		
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;			
		}
	}
	return curleft;
}
function findTop(obj) {
	var curTop =  0;
	if (obj.offsetParent) {
		curTop = obj.offsetTop;		
		while (obj = obj.offsetParent) {
			curTop += obj.offsetTop;			
		}
	}
	return curTop;
}
function setMenu(active){
	var i1 = document.getElementById("menu-item1");
	var i2 = document.getElementById("menu-item2");
	var i3 = document.getElementById("menu-item3");
	var i4 = document.getElementById("menu-item4");
	var t1 = document.getElementById("top-bar");
	document.getElementById("hover_bar_item2").style.left= findLeft(i2);	
	document.getElementById("hover_bar_item3").style.left= findLeft(i3);	
	document.getElementById("hover_bar_item4").style.left= findLeft(i4);
	document.getElementById("hover_bar_item1").style.left= findLeft(i1) - 2;
	document.getElementById("hover_bar_item2").style.top= findTop(t1)-7;	
	document.getElementById("hover_bar_item3").style.top= findTop(t1)-7;	
	document.getElementById("hover_bar_item4").style.top= findTop(t1)-7;
	document.getElementById("hover_bar_item1").style.top= findTop(t1)-7;
	document.getElementById("nav-item2").style.top= findTop(t1);	
	document.getElementById("nav-item3").style.top= findTop(t1);	
	document.getElementById("nav-item4").style.top= findTop(t1);
	document.getElementById("nav-item1").style.top= findTop(t1);
	document.getElementById("nav-item1").style.left= findLeft(i1) - 2;	
	document.getElementById("nav-item3").style.left= findLeft(i3);	
	document.getElementById("nav-item2").style.left= findLeft(i2);
	document.getElementById("nav-item4").style.left= findLeft(i4);
	document.getElementById("hover_bar_item1").style.width = i1.offsetWidth;
	document.getElementById("hover_bar_item2").style.width = i2.offsetWidth;
	document.getElementById("hover_bar_item3").style.width = i3.offsetWidth;
	document.getElementById("hover_bar_item4").style.width = i4.offsetWidth;
	document.getElementById("menu-item1").style.width = i1.offsetWidth+1;
	document.getElementById("menu-item2").style.width = i2.offsetWidth;
	document.getElementById("menu-item3").style.width = i3.offsetWidth;
	document.getElementById("menu-item4").style.width = i4.offsetWidth;
	if(active != 0)
		try
		  {
		  document.getElementById("hover_bar_item"+active).style.visibility = 'visible';
		  }
		catch(err)
		  {
		  //Handle errors here
		  }
		
}

function subscribe(){
	
	var email = document.getElementById('email').value;
	
	if(!check_email(email)){
		alert("Please re-enter correct email address.");			
		return false;			
	}		
	else{
		 var url= 'ajax_newsletter_signin.php?email='+email;
		
		new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
							document.getElementById('footerTop-right').innerHTML = transport.responseText;						
							
						},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
	}
}


function hideDHTML(id)	{
	document.getElementById(id).style.visibility = 'hidden';	
	document.getElementById(id).style.display = 'none';		
	document.getElementById('overlay_' + id).style.width = 0 +"px";
	document.getElementById('overlay_' + id).style.height = 0 +"px";	
	document.getElementById('overlay_' + id).style.visibility='hidden';	
}


function opacity(id, opacStart, opacEnd, millisec) 
{ 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd)
	{ 
        for(i = opacStart; i >= opacEnd; i--) 
		{ 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
	else if(opacStart < opacEnd) 
	{ 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        	} 
    } 
} 

/*function adjust_popup_width(the_popup)
{
var popupwidth = 0;
var popupleft = 0;
var test = 0;
popupwidth = document.getElementById('pop_up_main_pic').offsetWidth+document.getElementById('pop_up_sub_pics').offsetWidth+70;
document.getElementById(the_popup).style.width = popupwidth+"px";
if(popupwidth <= 930)
	{
	popupleft = ((930/2)-(popupwidth/2)) ;
	}
document.getElementById(the_popup).style.left = document.getElementById('container').offsetLeft+popupleft+"px";
document.getElementById('close_img_popup').style.left = document.getElementById('pop_up_sub_pics').offsetLeft+document.getElementById('pop_up_sub_pics').offsetWidth+"px";
}*/


/*adjust_popup_width 
the_popup --> the id of the popup div
cat_type  --> the controller of the image for the max width per request
*/

function adjust_image_normal(isDoor)
{
	if(document.getElementById('image-normal').offsetWidth>315 && isDoor>0)
		{
		document.getElementById('image-normal').style.width = "315px";
		}
	
}


function adjust_popup_width(the_popup, isDoor)
{
	//alert(the_popup);
var popupwidth = 0; //width of the popup stored into the variable
var popupleft = 0; //left of the popup stored into the variable
var test = 0;
if(isDoor>0) //if cat_type == 1 the category is doors
	{
			//alert(document.getElementById('prime_image').offsetWidth);
		if(document.getElementById('prime_image').offsetWidth>500)
			{
			document.getElementById('prime_image').style.width = 500 + 'px';
			}
		document.getElementById('pop_up_main_pic_doors').style.width = document.getElementById('prime_image').offsetWidth;

			//alert(document.getElementById('the_description').offsetHeight);
			popupwidth = document.getElementById('pop_up_main_pic_doors').offsetWidth+document.getElementById('pop_up_sub_pics_doors').offsetWidth+document.getElementById('pop_up_desc_doors').offsetWidth+150;
	document.getElementById(the_popup).style.width = popupwidth+"px";
		
	//if(popupwidth <= 930)
	//{

		//calculate and try to center the popup
	popupleft = ((930/2)-(popupwidth/2)) ;
	//}

	//assign the calculated left to the popup
	document.getElementById(the_popup).style.left = document.getElementById('container').offsetLeft+popupleft+"px";
	document.getElementById('pop_up_sub_pics_doors').style.marginLeft="25px";
	document.getElementById('the_description').style.marginTop = 525 - document.getElementById('the_description').offsetHeight + "px";
	//assign a left style to close_img_popup div		  = get the style left of pop_up_desc                + // get the style width of pop_up_desc            - adjustment
	document.getElementById('close_img_popup').style.left = document.getElementById('pop_up_desc_doors').offsetLeft+document.getElementById('pop_up_desc_doors').offsetWidth-25+"px";
			
	}


else
	{
		//this section is the arrangement for the regular template
	popupwidth = document.getElementById('pop_up_main_pic').offsetWidth+document.getElementById('pop_up_sub_pics').offsetWidth+70;
	document.getElementById(the_popup).style.width = popupwidth+"px";
	if(popupwidth <= 930)
	{
	popupleft = ((930/2)-(popupwidth/2)) ;
	}
	document.getElementById(the_popup).style.left = document.getElementById('container').offsetLeft+popupleft+"px";
	document.getElementById('close_img_popup').style.left = document.getElementById('pop_up_sub_pics').offsetLeft+document.getElementById('pop_up_sub_pics').offsetWidth+"px";
	}
}

function changeOpac(opacity, id) 
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}



function getScrollWidth()
{
	var w = window.pageXOffset ||
	        document.body.scrollLeft ||
		    document.documentElement.scrollLeft;		           
    return w ? w : 0;
}
		
function getScrollHeight()
{
	var h = window.pageYOffset ||
		    document.body.scrollTop ||
		    document.documentElement.scrollTop;		           
	return h ? h : 0;
}
		
		
function simple_show_res_dhtml(thiselid)
{
			//alert(thiselid)\
			//curr;
			//src_img;
	scrolled = getScrollHeight();
	arrayPageSize = getPageSize();
	document.getElementById(thiselid).style.visibility='visible';
	document.getElementById(thiselid).style.display='block';
	document.getElementById(thiselid).style.top = document.getElementById('middle').offsetTop;
	document.getElementById(thiselid).style.left = document.getElementById('middle').offsetLeft;
	document.getElementById('overlay_'+thiselid).style.visibility='visible';
	document.getElementById('overlay_'+thiselid).style.width = arrayPageSize[0] +"px";
	document.getElementById('overlay_'+thiselid).style.height = arrayPageSize[1] +"px";
	//document.getElementById('close_img_popup').style.left = document.getElementById('pop_up_sub_pics').offsetLeft+230+"px";
	opacity('overlay_'+thiselid, 0, 70, 1000);

}
		
function simple_show_res_dhtml_2(thiselid)
{
		//alert(document.getElementById('txt_esp_nat').offsetLeft);
	document.getElementById(thiselid).style.visibility='visible';
	document.getElementById(thiselid).style.display='block';
	document.getElementById(thiselid).style.top = document.getElementById('txt_esp_nat').offsetTop;
	document.getElementById(thiselid).style.left = document.getElementById('txt_esp_nat').offsetLeft;
	//document.getElementById(thiselid).style.top = document.getElementById('middle').offsetTop;
	//document.getElementById(thiselid).style.left = document.getElementById('middle').offsetLeft;
}
	
function hide_res_dhtml_2(thiselid)
{
	//alert(document.getElementById('txt_esp_nat').offsetLeft);		
	document.getElementById(thiselid).style.visibility='hidden';
	document.getElementById(thiselid).style.display='none';
	
}			
	
//function show_res_dhtml(thiselid)
function show_res_dhtml(thiselid, cat_transfer)
{
			//alert(thiselid)\
			//curr;
			//src_img;
	if(normal_pic=="")
	{
		//normal_pic = "1addl-artisticbarchair.jpg";
	scrolled = getScrollHeight();
	arrayPageSize = getPageSize();
	document.getElementById(thiselid).style.visibility='visible';
	document.getElementById(thiselid).style.display='block';
	document.getElementById(thiselid).style.top = document.getElementById('middle').offsetTop;
	document.getElementById(thiselid).style.left = document.getElementById('middle').offsetLeft;
	document.getElementById('overlay_'+thiselid).style.visibility='visible';
	document.getElementById('overlay_'+thiselid).style.width = arrayPageSize[0] +"px";
	document.getElementById('overlay_'+thiselid).style.height = arrayPageSize[1] +"px";
	opacity('overlay_'+thiselid, 0, 70, 1000);
	//adjust_popup_width(thiselid);
	adjust_popup_width(thiselid,cat_transfer);
	show_border(current, 'pop_up_sub_pics',0);
	}
	else
	{
	scrolled = getScrollHeight();
	arrayPageSize = getPageSize();
	document.getElementById(thiselid).style.visibility='visible';
	document.getElementById(thiselid).style.display='block';
	document.getElementById(thiselid).style.top = document.getElementById('middle').offsetTop;
	document.getElementById(thiselid).style.left = document.getElementById('middle').offsetLeft;
	document.getElementById('overlay_'+thiselid).style.visibility='visible';
	document.getElementById('overlay_'+thiselid).style.width = arrayPageSize[0] +"px";
	document.getElementById('overlay_'+thiselid).style.height = arrayPageSize[1] +"px";
	opacity('overlay_'+thiselid, 0, 70, 1000);
	document.getElementById('prime_image').src=normal_pic;
	//alert(document.getElementById('pop_up_main_pic').offsetWidth+" "+document.getElementById('pop_up_sub_pics').offsetWidth);
	//adjust_popup_width(thiselid);
	adjust_popup_width(thiselid,cat_transfer);
	show_border(current, 'pop_up_sub_pics',0);
	}
}


function change_from_thumb(src_img, div_source, curr)
{
	document.getElementById('prime_image').src = src_img;
	document.getElementById('pop_up_sub_pics'+current).style.border="2px solid white";
	div_source.style.border="2px solid #333333";
	document.getElementById('close_img_popup').style.left = document.getElementById('pop_up_sub_pics').offsetLeft+230+"px";
	//alert(document.getElementById('pop_up_sub_pics').offsetLeft);
	adjust_popup_width('statement');
	current = curr;
}

function show_border(div_source, pre,the_style)
{
	if(the_style==1)
	{
		document.getElementById(pre+div_source).style.border="0px";
		document.getElementById(pre+div_source).style.border="2px solid #c2c2c2";
	}
	else
	{
		//alert(pre+div_source);
		try
			{
			document.getElementById(pre+div_source).style.border="0px";	
			document.getElementById(pre+div_source).style.border="2px solid #333333";
			}
		catch(err)
			{
			}
	}
}
		
function hide_border(div_source, pre,the_style)
{
	if(div_source != current)
	{
		if(the_style==1)
		{
			document.getElementById(pre+div_source).style.border="0px";
			document.getElementById(pre+div_source).style.border="2px solid white";
		}
		else
		{
			try
				{
				document.getElementById(pre+div_source).style.border="0px";	
				document.getElementById(pre+div_source).style.border="2px solid #FFF";
				}
			catch(err)	
				{
					
				}
		}
	}
}

function hide_border_init(div_source, pre,the_style)
{
	if(the_style==1)
	{
		document.getElementById(pre+div_source).style.border="0px";
		document.getElementById(pre+div_source).style.borderBottom="1px solid white";
	}
	else
	{	
		document.getElementById(pre+div_source).style.border="2px solid #FFF";
	}
}


function change_zoomset(normal, zoom,the_thumb_id, pop_img)
{
		hide_border_init(current, 'pop_up_sub_pics',1);
		document.getElementById('image-normal').src =normal;
		
		//alert(current);
		document.getElementById('thumb_'+current).style.border="0px solid white";
		document.getElementById('thumb_'+current).style.border="2px solid white";
		show_border(the_thumb_id, 'thumb_',1);
		document.getElementById('cover_active').style.display="block";
		document.getElementById('cover_active').style.position="absolute";
		document.getElementById('cover_active').style.width="80px";
		document.getElementById('cover_active').style.height="80px";
		document.getElementById('cover_active').style.top=document.getElementById('thumb_'+the_thumb_id).offsetTop;
		document.getElementById('cover_active').style.left=document.getElementById('thumb_'+the_thumb_id).offsetLeft;
		zoom_init(zoom);
		normal_pic=pop_img;
		global_curr=the_thumb_id;
		current = the_thumb_id;
		
}



	
function req_shipping_quote()
{
	document.getElementById('shipping_quote_textlower').style.display="none";
	document.getElementById('shipping_quote_textupper').style.display="none";
	document.getElementById('shipping_quote_form').style.display="block";
}

function req_shipping_quote_thankyou()
{
	document.getElementById('shipping_quote_form').style.display="none";
	document.getElementById('shipping_thankyou').style.display="block";
}
	

	
	
function zoom_init(zoomimg)
{		
	imgzoomstring = zoomimg;			
	zoom.bigImage.src = imgzoomstring;
	//zoom.initZoom();
}
		
			

		

function txt_email(txt_input)
{
	if(email_checker == 0)
	{
		txt_input.value = "";
		email_checker=1;
	}
}


function check_txt_email(txt_input)
{
	if(txt_input.value=="")
	{
		txt_input.value = " enter email address";
		email_checker = 0;
	}
}

function revert_stain()
{
document.getElementById('txt_esp_nat').style.position = "";	
}

function normal_stain()
{
document.getElementById('txt_esp_nat').style.position = "relative";
}


function hide_dhtml(thiselid)
{
document.getElementById(thiselid).style.display='none';
}



function subscribe_right_section(){
	
	var email = document.getElementById('Sign_me_up').value;
	
	if(!check_email(email)){
		alert("Please re-enter correct email address.");			
		return false;			
	}		
	else{
		 var url= 'ajax_newsletter_signin.php?email='+email;
		
		new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
							document.getElementById('newsletter_subscribe_section').style.paddingTop = '287px';
							document.getElementById('newsletter_subscribe_section').innerHTML = "<span style='color:#FFFFFF;font-size:18px;font-weight:bold;text-align:center;'>Thank you for subscribing to our newsletter!</span>" ;/*transport.responseText;						*/
							setCookie('subscribed',1,1);
						},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
	}
}

function contactSend() {
	var contact_name = $F('contact_name');
	var email = $F('contact_email');
	var comments = $F('message');

	
	 var newswrite_true = 'no';
	
	 if(contact_name == ""){
		 alert("Please enter name.");
		 return;
	 }
	 if(!check_email(email)){
		 alert("Your email address is invalid. Please enter again.");
		 return;
	 }
	 if(document.getElementById('newscheckbox')){
		 if (document.getElementById('newscheckbox').checked == true){
		 	newswrite_true = 'yes';
		 }
	}
	
	 var url = 'contactemail.php';
	 var pars = 'name=' + contact_name + '&contact_email=' + email + '&comments=' + comments + '&newswrite_true=' + newswrite_true;
	
	 var myAjax = new Ajax.Updater({success: 'container_right_bottom'},url,
	 {
	 method:'post',
	 parameters: pars
	 //onSuccess: pageTracker._trackPageview("contact-thankyou.html"),
	 //onFailure: reportError
	 });
	 
} 


function getInfo()
{
	var contact_name = $F('name');
	var email = $F('email');
	
	
	
	
	 if(contact_name == ""){
		 alert("Please enter name.");
		 return;
	 }
	 if(!check_email(email)){
		 alert("Your email address is invalid. Please enter again.");
		 return;
	 }
	 
	
	 	
	  var url= 'infomail.php?name=' + contact_name + '&contact_email=' + email;
		
		new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
							document.getElementById('info-form').innerHTML ="";							
							document.getElementById('info-form').style.backgroundImage = 'url(images/VK-built-in-thankyou.jpg)';						
							document.getElementById('info-form').style.width = "397px";						
							document.getElementById('info-form').style.height = "198px";						
							document.getElementById('info-form').style.marginTop = "8px";
							
						},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
}

function get_cta(the_cta,the_email,the_parent)
{
	var email = document.getElementById(the_email).value;
	
	if(!check_email(email)){
		alert("Please re-enter correct email address.");			
		return false;			
	}

	 var url= ' cta_link_mailer.php?contact_email=' + email + '&the_cta='+the_cta;
	new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
				if(the_parent=='footerTop-left')
					{
						if(the_cta=='CP_cta')
							{
							document.getElementById(the_parent).innerHTML='<div style="width:100%; height:100%; background-color:#fff; color:#000; font-size:18px; padding:0; background-repeat:no-repeat; background-image:url(\'images/CP_cta-thanks.png\')">&nbsp;</div>';	
							}
						else
							{
							document.getElementById(the_parent).innerHTML='<div style="width:100%; height:100%; background-color:#fff; color:#000; font-size:18px; padding:0; background-repeat:no-repeat; background-image:url(\'images/VKCAT_cta-thanks.png\')">&nbsp;</div>';	
							}	
					}
				else
					{	
					document.getElementById(the_parent).innerHTML='<div style="width:100%; height:100%; background-color:#fff; color:#000; font-size:18px; padding:185px 0 0 0px; background-repeat:no-repeat; background-image:url(\'images/thanks-bg-hz.png\')">&nbsp;</div>';
					}
							
				},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
	
}


function cta_askQ(the_product,the_email,the_message,the_ticker,the_parent)
{
	var email = document.getElementById(the_email).value;
	var message = document.getElementById(the_message).value;
	var countmein=0;
	if(document.getElementById(the_ticker).checked == true)
		{
		countmein=1;	
		}
	
	if(!check_email(email)){
		alert("Please re-enter correct email address.");			
		return false;			
	}

	 var url= ' cta_AQ_mailer.php?contact_email=' + email +'&message='+message+'&countmein='+countmein+ '&the_product='+the_product;
	new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
							document.getElementById(the_parent).innerHTML='<div style="width:187px; height:388px; background-color:#fff; color:#000; font-size:14px; padding:20px;background-repeat:no-repeat;background-image:url(\'images/thanks-bg-hz-qa.png\')">&nbsp;</div>';
							
						},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
	
}

function preloadImagePopup(dynaImage)
{
PImage1 = new Image(); 
PImage1.src = "../images/popup/optin/bg.jpg";
PImage2 = new Image(); 
PImage2.src = "../images/popup/optin/bg2.png";
PImage4 = new Image(); 
PImage4.src = "../images/popup/optin/bg2.png";
PImage3 = new Image(); 
if(dynaImage!="")
	{
	PImage3.src = "../images/popup/optin/"+dynaImage;
	}
	
}

function proceedFRM(dynaImage, dynaURL,the_m_type)
{	
	
	if(the_m_type=='doors')
		{
		document.getElementById('visualization').style.backgroundImage = 'url(images/popup/optin/bg2.png)';	
		}
	else
		{
		document.getElementById('visualization').style.backgroundImage = 'url(images/popup/optin/bg2_products.png)';	
		}	
	document.getElementById('visualization').innerHTML =  '<img src="images/popup/optin/'+dynaImage+'" style="margin:-2px 0 0 -2px; float:left;">'+"\n"+"<div id='form'>"+"\n"+"<span>Name:</span><input type='text' name='RUName' id='RUName'>"+"\n"+"<br><br><span>Email:</span><input type='text' name='RUEmail' id='RUEmail'>"+"\n"+"<input type='image' src='images/popup/optin/button2.png' onclick='GA_trackit_dhtml("+'"'+'freevisualization'+'"'+",2);sendMeVisualization(\""+dynaImage+"\",\""+dynaURL+"\",\""+the_m_type+"\")'>"+"</div>"+"\n"+'<a id="close_img_popup_visualization" style="border:0 none; display:block; height:27px; left:905px; position:absolute; top:0px; width:36px;" href="javascript: hideDHTML(\'visualization\');" onclick="hideDHTML(\'visualization\');"><img src="images/popup/optin/close_05.png" border="0" alt="Close" onclick="hideDHTML(\'visualization\');"></a>';
}


function str_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 1103.1210
    // discuss at: http://phpjs.org/functions/str_replace    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'    var i = 0,
        j = 0,
        temp = '',
        repl = '',
        sl = 0,        fl = 0,
        f = [].concat(search),
        r = [].concat(replace),
        s = subject,
        ra = r instanceof Array,        sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    } 
    for (i = 0, sl = s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }        for (j = 0, fl = f.length; j < fl; j++) {
            temp = s[i] + '';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {                this.window[count] += (temp.length - s[i].length) / f[j].length;
            }
        }
    }
    return sa ? s : s[0];
   }

function finish_sending_from_popup()
{
	
hideDHTML('visualization'); 	
}






function sendMeVisualization(dynaImage,dynaURL,the_m_type)
{


	var email = document.getElementById('RUEmail').value;
	var RUName = document.getElementById('RUName').value;
	
	//alert('send email'+email+" - "+RUName);
	
	if(!check_email(email)){
		alert("Please re-enter correct email address.");			
		return false;			
	}
	
	var url= 'popup_free_visualization_mailer.php';
	var pars= 'contact_email=' + email +'&RUName='+RUName+'&dynaURL='+dynaURL+'&the_m_type='+the_m_type;
	var cookiename = str_replace(".html","",dynaURL);
	
	new Ajax.Request(url,{
			method:'post',
	 		parameters: pars,
			onSuccess: function(transport){
						//alert('success');
							//document.getElementById('visualization').style.backgroundImage = 'url(images/popup/optin/thank_you.png)';
							//document.getElementById('visualization').innerHTML='<img src="images/popup/optin/'+dynaImage+'" style="margin:-2px 0 0 -2px; float:left;">'+"\n"+'<div style="float: left;margin-left: 25px;margin-top: 185px;width: 400px; color:#FF6C01;"><h2></h2><span style="font-size:18px;"></span></div>'+'<a id="close_img_popup_visualization" style="border:0 none; display:block; height:27px; left:905px; position:absolute; top:0px; width:36px;" href="javascript: hideDHTML(\'visualization\');" onclick="hideDHTML(\'visualization\');"><img src="images/popup/optin/close_05.png" border="0" alt="Close" onclick="hideDHTML(\'visualization\');"></a>';
							setCookie(cookiename,1,1);
							window.location = "http://www.victorklassen.com/thank-you-visualization.html?red="+dynaURL+"&si="+dynaImage;
							//setTimeout("finish_sending_from_popup()", 7000);
						},	
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
	
	/*var url= 'popup_free_visualization_mailer.php?contact_email=' + email + '&amp;RUName=' + RUName + '&amp;dynaURL=' + dynaURL;
	alert(url);
	new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
							//document.getElementById('footerTop-right').innerHTML = transport.responseText;						
							document.getElementById('visualization').innerHTML='<img src="images/popup/optin/'+dynaImage+'" style="margin:-2px 0 0 -2px; float:left;">'+"\n"+'<div style="float: left;margin-left: 25px;margin-top: 185px;width: 400px; color:#FF6C01;"><h2>Thank You</h2><span style="font-size:18px;">Your request is already sent to your email.</span></div>'+'<a id="close_img_popup_visualization" style="border:0 none; display:block; height:27px; left:905px; position:absolute; top:0px; width:36px;" href="javascript: hideDHTML(\'visualization\');" onclick="hideDHTML(\'visualization\');"><img src="images/popup/optin/close_05.png" border="0" alt="Close" onclick="hideDHTML(\'visualization\');"></a>';
							
						},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); */
	
	 //setTimeout("finish_sending_from_popup", 5000);
	 //alert('send email');
	//return false;
}

function subscribe_cta(reply_container){
	
	var email = document.getElementById('NdesignEmail').value;
	
	if(!check_email(email)){
		alert("Please re-enter correct email address.");			
		return false;			
	}		
	else{
		 var url= 'ajax_newsletter_signin.php?email='+email;
		
		new Ajax.Request(url,{
			method:'get',
			onSuccess: function(transport){
				var img_bg = 'url("images/cta-left_070711-ty.png")';
							if(reply_container == 'footerTop-left')
								{
								img_bg = 'url("images/CTA-bottom_070711-ty.png")';	
								}
							document.getElementById(reply_container).style.backgroundImage=img_bg;	
							document.getElementById(reply_container).innerHTML = "";
						},
			onFailure: function(){
				alert('error while connection, please try again!');
				return false;
			}
		}); 
	}
}


