function GotoTire(dir,cat,subCatName)
{
	Redireccionar(dir);
	setCookie('TireCat', cat, 365);
	setCookie('TireSubCat', dir, 365);
	setCookie('SubCatName', subCatName, 365);
}

var state = 'none';

function showhide(layer_ref) 
{
	if (state == 'block') {
		state = 'none';
	}
	else {
		state = 'block';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layer_ref].display = state;
	}
	if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);
		hza.style.display = state;
	}
} 


function GotoKendaRacing()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/kenda-racing.aspx');
}

function GotoKendaStory()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/kenda-story.aspx');
}

function GotoNewsEvents()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/news_events.aspx');
}

function GotoCareers()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/careers.aspx');
}

function GotoContactUs()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/contactus.aspx');
}

function GotoDealerWarranty()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/dealers/warranty.aspx');
}

function GotoDealerContactUs()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/dealers/contact-us.aspx');
}

function GotoDealerLogin()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/dealers/login.aspx');
}

function GotoSubmitResume()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/home/careers/submit-resume.aspx');
}

function Redireccionar(dir)
{
	//alert(dir);
	if (dir!='0')
	{
		window.location.href=dir;
	}
	/*Use error message, something like Please select a category*/
}

function GotoHomePage()
{
	var lang=getLanguage();
	Redireccionar('/'+lang+'/Home.aspx');
}

function Goto(dir)
{
	Redireccionar(dir);
	setCookie('leftmenu', dir, 365);
}


/**
 * @author maria.corrales
 */
//mcorrales; funtion that redirects to the news page selected by category
function selectnewsCategory(selectedopt)
{
    var redirectWin = "#";
    if (selectedopt != "")
    {
        redirectWin = selectedopt + "-news.aspx";
    }
    var lang=getLanguage();
    location.href ='/' + lang + '/Home' + '/news_events/' + redirectWin;
}

//mcorrales; funtion that redirects to the events page selected by category
function selecteventsCategory(selectedopt)
{
    var redirectWin = "#";
    if (selectedopt != "")
    {
        redirectWin = selectedopt + "-events.aspx";
    }
    var lang=getLanguage();
    location.href ='/' + lang + '/Home' + '/news_events/' + redirectWin;
}

/** this function changes the images  **/
function swap(image) 
{
	document.getElementById("imgmain").src = image.src;
	document.getElementById("imgZoom").value = image.id;
}

function zoomin(){
	debugger;
	var currentImgSize = document.getElementById("imgmain").width+30;
	if (currentImgSize <= 600)
		document.getElementById("imgmain").width = currentImgSize;
}
	
function zoomout(){
	var currentImgSize = document.getElementById("imgmain").width-30;
	if (currentImgSize >= 200)
		document.getElementById("imgmain").width = currentImgSize;
}
/** This function shows a pop up of the main product image when it is clicked **/
function popitup(image)
{
	var allBody = document.createElement("HTML");
	var headContent = document.createElement("HEAD");
	var bodyContent = document.createElement("BODY");
	var divConteiner = document.createElement("DIV");
		divConteiner.id = "contentPopup";
	var divContent = document.createElement("DIV");
		divContent.id = "content";
	var centerContainer = document.createElement("CENTER");

	var title= document.createElement("title");
		title.appendChild(document.createTextNode("Product Image"));  
	headContent.appendChild(title);  

	var imageZoomIn = document.createElement("IMG");
		imageZoomIn.src = '/media/25783/Zoom-In-icon.png';
		imageZoomIn.style.border= "0";

	var imageZoomOut = document.createElement("IMG");
		imageZoomOut.src = '/media/25788/Zoom-Out-icon.png';
		imageZoomOut.style.border= "0";

	var linkZoomIn = document.createElement("A");
		linkZoomIn.id = "zoomin";
		linkZoomIn.appendChild(imageZoomIn);
		linkZoomIn.href = "javascript:void(0);";
		linkZoomIn.setAttribute('onclick', "javascript:if (document.getElementById('imgmain').width+30 <= 600){document.getElementById('imgmain').width = document.getElementById('imgmain').width+20;document.getElementById('imgmain').height= document.getElementById('imgmain').height+30}");
	divContent.appendChild(linkZoomIn);

	var linkZoomOut = document.createElement("A");
		linkZoomOut.id = "zoomout";
		linkZoomOut.appendChild(imageZoomOut);
		linkZoomOut.href = "javascript:void(0);";
		linkZoomOut.setAttribute('onclick', "javascript:if (document.getElementById('imgmain').width-30 >= 165){document.getElementById('imgmain').width = document.getElementById('imgmain').width-20;document.getElementById('imgmain').height= document.getElementById('imgmain').height-30;}");
		linkZoomOut.style.margin = "0 0 0 20px";
	divContent.appendChild(linkZoomOut);

	var theBR = document.createElement('br');
	divContent.appendChild(theBR);

	divConteiner.appendChild(divContent);

	var currentimage = document.createElement("IMG");
		currentimage.src = document.getElementById("imgZoom").value;
		currentimage.id= "imgmain";
		currentimage.width= "350";
	centerContainer.appendChild(currentimage);
	divContent.appendChild(centerContainer);

	divConteiner.appendChild(divContent);
	bodyContent.appendChild(divConteiner);
	allBody.appendChild(headContent);
	allBody.appendChild(bodyContent);
	var w = 570;
	var h=524;
	var x=(screen.width - w) / 2;
	var y=(screen.height - h) / 2;

	var win = window.open('', 'Image', 'resizable=1,scrollbars=1,status=no,width='+w+',height='+h+',left='+x+',top='+y);
	win.document.writeln(allBody.innerHTML);
	win.document.close();
}


//Normal is 190 x 223
function ReSizeProductImage()
{
return;
	var MAXW=190;
	var MAXH=223;
	var productimage=document.getElementById('imgmain');
	if (productimage!=null)
	{
	
		if (productimage.width>MAXW)
		{
			var ratio= MAXW/productimage.width;
			productimage.width=MAXW;
			if (productimage.height>MAXH)
			{
				productimage.height=productimage.height*ratio;
			}
		}
		else if (productimage.height>MAXH)
		{
			var ratio= MAXH/productimage.height;
			productimage.height=MAXH;
			if (productimage.width>MAXW)
			{
				productimage.width=productimage.width*ratio;
			}
		}
	}
}

//Normal is 162 x 129
function ReSizeFeaturedImage()
{
return;
	var MAXW=97;
	var MAXH=129;
	var productimage=document.getElementById('imgfeat');
	if (productimage!=null)
	{
		if (productimage.height>MAXH)
		{
			var ratio= MAXH/productimage.height;
			productimage.height=MAXH;
			if (productimage.width>MAXW)
			{
				productimage.width=productimage.width*ratio;
			}
		}
		else if (productimage.width>MAXW)
		{
			var ratio= MAXW/productimage.width;
			productimage.width=MAXW;
			if (productimage.height>MAXH)
			{
				productimage.height=productimage.height*ratio;
			}
		}
	}
}

