// sliding to the left
function slide_left(clicks, max_clicks, scoll_val)
{
	if (clicks < max_clicks)
	{
		++clicks;
		$('#left .sertificates .sert').animate({scrollLeft: (scoll_val * clicks)}, 200)
	}
	return clicks;
}
// sliding to the right
function slide_right(clicks, max_clicks, scoll_val)
{
	if (clicks > 0)
	{
		--clicks;
		$('#left .sertificates .sert').animate({scrollLeft: (scoll_val * clicks)}, 200)
	}
	return clicks;
}
function shopImages(){
	elems=$('img.bigimg').get();
	if(elems.length>0){
		sizes=new Array();
		for(a=0;a<elems.length;a++){
			sizes[a]=elems[a].offsetWidth;
			elems[a].style.display='none';
		}
		cnsize=$('#container').get(0).offsetWidth-20;
		for(a=0;a<elems.length;a++){
			if(sizes[a]>cnsize){
				elems[a].style.width=cnsize+'px';
			}
			elems[a].style.display='inline';
		}
	}
	
}
window.onresize=shopImages;
$(document).ready(function(){
	
	shopImages();
	
	
	if($(".iepng")!=null){
		$(".iepng").ifixpng();
	}
	// sertificates slide
	if($('#left .sertificates')!=null){
		$('#left .sertificates .sert').css({overflow: "hidden"});
		var total_elms = $('#left .sertificates .sert ul li').length;
		var show_elms = 1;
		var t_full = Math.ceil(total_elms / show_elms) * show_elms;
		var gal_width = t_full * 120;
		var clicks = 0;
		var scoll_val = 120;
		var max_clicks = Math.ceil(total_elms / show_elms) - 1;
		$('#left .sertificates .sert ul').css({width: gal_width});
		$('#left .sertificates .nav_r a').bind("click", function(e)
			{ 
				e.preventDefault();
				clicks = slide_left(clicks, max_clicks, scoll_val);
			}
		);
		$('#left .sertificates .nav_l a').bind("click", function(e)
			{
				e.preventDefault();
				clicks = slide_right(clicks, max_clicks, scoll_val);
			}
		);
		// products image change
		$("#product .r_info .images li a").bind("click", function(e)
			{
				e.preventDefault();
				var img = $(this).attr("href");
				if (img && img != '')
				{
					$("#p_img img").remove();
					$("<img>").attr({src: img}).appendTo("#p_img");
				}
			}
		);
	}
	// comparison block border
	if($("#comparison")!=null){
		var comp_t_w = $("#comparison .items").width();
		var comp_w = $("#comparison").width();
		if (comp_t_w > comp_w){
			$("#comparison .blck_1").css({width: comp_t_w});
		}
	}
	// select all products
	if($("#catalog_2")==null){
		return false;
	}
	var check_elms = $("#catalog_2 .list .check :input").length;
	$("#catalog_2 .sel_all :input").bind("click", function()
		{
			if ($(this).attr("checked"))
			{
				$("#catalog_2 .list .check :input").each(function()
					{
						if (!$(this).attr("checked"))
						{
							$(this).attr({checked: "checked"});
						}
					}
				);
			}
			else
			{
				$("#catalog_2 .list .check :input").each(function()
					{
						if ($(this).attr("checked"))
						{
							$(this).attr({checked: ""});
						}
					}
				);
			}
		}
	);
	$("#catalog_2 .list .check :input").bind("click", function()
		{
			if (!$(this).attr("checked"))
			{
				if ($("#catalog_2 .sel_all input:checked"))
				{
					$("#catalog_2 .sel_all input").attr({checked: ""});
				}
			}
			else
			{
				var checked_elms = $("#catalog_2 .list .check input:checked").length;
				if (check_elms == checked_elms)
				{
					$("#catalog_2 .sel_all input").attr({checked: "checked"});
				}
			}
		}
	);
	setTimeout('if(document.getElementById(\'parent_faq_hd\')!=null){document.getElementById(\'parent_faq_hd\').value=\'0\';}',3300);
});

	function myajax2(url,dattt,object,p_callback,return_xml,met) {
	   var http_request = false;
	
	    if (window.XMLHttpRequest) { // Mozilla, Safari, Others..
	        http_request = new XMLHttpRequest();
	        if (http_request.overrideMimeType) {
	            http_request.overrideMimeType('text/xml');
	        }
	    } else if (window.ActiveXObject) { // IE
	        try {
	            http_request = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	            try {
	            http_request = new ActiveXObject("Msxml2.XMLHTTP");
	            } catch (e) {}
	        }
	    }
	
	    if (!http_request) {
	        alert('Giving up :( Cannot create an XMLHTTP instance');
	        return false;
	    }
	    http_request.onreadystatechange = function() {
	       if (http_request.readyState == 4) {
	           if (http_request.status == 200) {
	             if (return_xml) {
	                   p_callback(http_request.responseXML,object);
	               } else {
	                   p_callback(http_request.responseText,object);
	               }
	           } else {
	           		object.requestHandler(http_request.status);
	           }
	       }
	   }
	    http_request.open(met, url, true);
	    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
	    http_request.send(dattt);
	
	}
	
	
	function preparePrint() {
		if(typeof(Element)!='undefined'){
			Element.hide('leftMenu');
	    	Element.hide('rightColumn');
	    	Element.hide('footer');
	    	Element.hide('header');
	    	Element.hide('printLink');

	    	$('printContent').style.width = '800px';
	    	$('content').style.width = '800px';

	    	Element.show('noprint');
		}
	}

	function removePrint() {

	    Element.show('leftMenu');
	    Element.show('rightColumn');
	    Element.show('footer');
	    Element.show('header');
	    Element.show('printLink');

	    $('printContent').style.width = '100%';
	    $('content').style.width = '100%';

	    Element.hide('noprint');
	}

	function varitext(text){
	    text=document
	    print(text)
	}
	
