var current_img = 1;
var intval = "";
function start_Int(imgNo){
    if(intval==""){
        current_img = imgNo;
      intval=window.setInterval("switch_header("+imgNo+")",5000);
  }else{
      stop_Int();
  }
}

function stop_Int(){
    if(intval!=""){
      window.clearInterval(intval);
      intval="";
  }
}
    
// email cloaking function

function	cloak( c_user , c_domain_sld , c_domain_tld , c_caption , c_class )

{

	c_mail = c_user + '@' + c_domain_sld + '.' + c_domain_tld;



	if( c_caption == '' )

	{

		c_caption = c_mail; 

	}



	if( c_class != '' )

	{

		c_cls = ' class="' + c_class + '"';

	}

	else

	{

		c_cls = ''; 

	}

	document.write( '<a href="mailto:' + c_mail + '"'+ c_cls +'>'+ c_caption + '</a>'  );

}

function ShowDiv(boxid){
   document.getElementById(boxid).style.visibility="visible";
}

function HideDiv(boxid){
   document.getElementById(boxid).style.visibility="hidden";
}

function showMessage(messageID){
    if(typeof($('#ifr_'+messageID) != "undefined")){
        $('#ifr_'+messageID).show();
    }
//    var left = ($(window).width() - 465) / 2;
    var top = $(window).scrollTop() + 150;
//    $('#'+messageID).css('left',left);
    $('#'+messageID).css('top',top);
    $('#'+messageID).css('z-index',2);
    $('#kite_body').append('<div onclick="hideMessage(\''+messageID+'\')" id="dimmed_'+messageID+'" style="position:absolute;display:none;left:0;top:0;width:'+$(document).width()+'px;height:'+$(document).height()+'px;z-index:1;background-color:#000;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity: 0.7;opacity: 0.7;">&nbsp;</div>');
    $('#dimmed_'+messageID).show();
    $('#'+messageID).css('visibility','visible');
    $('#'+messageID).show();
}

function hideMessage(messageID){
    if(typeof($('#ifr_'+messageID) != "undefined")){
        $('#ifr_'+messageID).hide();
    }
    $('#'+messageID).hide();
    $('#dimmed_'+messageID).fadeOut(500);
    $('#kite_body').remove('#dimmed_'+messageID);
    $('.t-shop-form td').css('background','#FFFFFF');
}

function switch_header(){
	var next_img;
	if(current_img == 5) current_img = 1;
	next_img = current_img + 1;
	if(next_img == 5) next_img = 1;
	$('#head_elem_'+current_img).fadeOut(400);
	$('#head_elem_'+next_img).fadeIn(400);
	$('.d-h-nav a').removeClass('act');
	$('#head_link_'+next_img).addClass('act');
	current_img++;
}

function switchHeadImg(imgNo){
    stop_Int();
    start_Int(imgNo);
	$('.d-h-element').fadeOut(400);
	$('#head_elem_'+imgNo).fadeIn(400);
	$('.d-h-nav a').removeClass('act');
	$('#head_link_'+imgNo).addClass('act');    
}

function sendShopMail(prodID){
    if(!$('#name_'+prodID).val().length){
        $('#td_name_'+prodID).css('background','#FFC9C9');
        return false;
    }
    if(!$('#email_'+prodID).val().length){
        $('#td_email_'+prodID).css('background','#FFC9C9');
        return false;
    }
    $.post('/ajax.php?action=shop_mail', 'name='+$('#name_'+prodID).val()+'&phone='+$('#phone_'+prodID).val()+'&email='+$('#email_'+prodID).val()+'&p_name='+$('#p_name_'+prodID).val()+'&from='+$('#from_'+prodID).val(), function(data) {
        alert('Thank You, Your message has been sent. You will receive an answer as soon as possible.');
        hideMessage(prodID);
    });
    return true;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
