function submitForm(frm)
{
    s = frm.code.value.split("_");
    frm.sort.value = s[0];
    frm.sort_type.value = s[1];
    frm.code.value = "";
    frm.submit();
}

function showDesc(id1, id2)
{
	var block1 = document.getElementById(id1);
	var block2 = document.getElementById(id2);
	
	block1.style.display = 'block';
	block2.style.display = 'none';
}



function MM_findObj(n, d) 
{ 
    var p,i,x; 
    if(!d) d=document; 
    if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
        d=parent.frames[n.substring(p+1)].document; 
        n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
    {
        x=d.forms[i][n];
    }
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    {
        x=MM_findObj(n,d.layers[i].document);
    }
    if(!x && document.getElementById) 
    {
        x=document.getElementById(n);
    } 
    return x;
}

function P7_autoLayers() 
{ 
    var g,b,k,f,args=P7_autoLayers.arguments;
    var a = parseInt(args[0]);
    if(isNaN(a)) a=0;
    if(!document.p7setc) 
    {
        p7c=new Array();
        document.p7setc=true;
        for (var u=0;u<10;u++) 
        {
            p7c[u] = new Array();
        }
    }
    for(k=0; k<p7c[a].length; k++) 
    {
        if((g=MM_findObj(p7c[a][k]))!=null) 
        {
            b=(document.layers)?g:g.style;
            b.visibility="hidden";
			b.display="none";
            try
            {
                    document.search_form.search_field.style.visibility = "visible";
            }
            catch (e)
            {
            }
        }
    }
    for(k=1; k<args.length; k++) 
    {
        if((g=MM_findObj(args[k])) != null) 
        {
            b=(document.layers)?g:g.style;
            b.visibility="visible";
			b.display="block";
			//b.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
            f=false;
            for(j=0;j<p7c[a].length;j++) 
            {
                if(args[k]==p7c[a][j]) 
                {
                    f=true;
                }
            }
            if(!f) 
            {
                p7c[a][p7c[a].length++]=args[k];
            }
        }
    }
}

function clearFilters()
{
    var frm = document.filters;
    var len = frm.elements.length;
    for (var i = 0; i < len; i++)
    {
	    if (frm.elements(i).options)
	    {
		    frm.elements(i).options(0).selected = true;
	    }
	}
}

function filterFilters()
{
	var frm = document.filters;
	var len = frm.elements.length;
	for (var i = 0; i < len; i++)
	{
		if (frm.elements(i).options)
		{
			if (frm.elements(i).options(0).selected)
			{
				frm.elements(i).disabled = true;
			}
		}
	}
}

function changeProductImageBorder(b)
{
	id = document.getElementById("product-image-large");
	id_link = document.getElementById("under-image-link");
	
	if(b == 1)
	{
		id.style.background = "url(images/product_image_bg_red.gif) no-repeat";
		id_link.style.color = "#FF0000";
		id_link.style.textDecoration = "underline";
	}
	else
	{
		id.style.background = "url(images/product_image_bg.gif) no-repeat";
		id_link.style.color= "#7A7A7A";
		id_link.style.textDecoration = "none";
	}
}

function showListType1(num)
{
	var navSectionName = new Array();
	navSectionName[1] = "price-link";
	navSectionName[2] = "review-link";
	navSectionName[3] = "spec-link";
	navSectionName[4] = "price-link2";
	navSectionName[5] = "review-link2";
	navSectionName[6] = "spec-link2";
	
	var sectionName = new Array();
	sectionName[1] = "price-section";
	sectionName[2] = "review-section";
	sectionName[3] = "spec-section";
	
	for(i = 1; i <= 3; i++)
	{
		if(i == num)
		{
			id = document.getElementById(navSectionName[i + 3]);
			id.style.display = "none";
			id = document.getElementById(navSectionName[i]);
			id.style.display = "";
			
			id = document.getElementById(sectionName[i]);

			id.style.display = "";
			

		}
		else
		{
			id = document.getElementById(navSectionName[i]);
			id.style.display = "none";
			id = document.getElementById(navSectionName[i + 3]);
			id.style.display = "";
			id = document.getElementById(sectionName[i]);

			id.style.display = "none";

		}
	}
	
	return 0;
}

function openWindow(url)
{
	window.open(url, "_blank");
}

function changeTopPicksBorder(num, ch)
{
	id_str1 = "top-picks-table1" + num;
	id_str2 = "top-picks-table2" + num;
	id_str3 = "top-picks-table3" + num;
	
	bimages = new Array();
	bimages[0] = "tl_corner";
	bimages[1] = "tr_corner";
	bimages[2] = "bl_corner";
	bimages[3] = "br_corner";
	
	if(ch == 0)
	{
		id = document.getElementById(id_str1);
		id.style.borderTop = "1px solid #FF0000";
		id = document.getElementById(id_str2);
		id.style.borderBottom = "1px solid #FF0000";
		id = document.getElementById(id_str3);
		id.style.borderLeft = "1px solid #FF0000";
		id.style.borderRight = "1px solid #FF0000";
		
		for(i = 0; i < 4; i++)
		{
			idstr = bimages[i] + num;
			id = document.getElementById(idstr);
			id.style.display = "none";
			idstr = bimages[i] + "_red" + num;
			id = document.getElementById(idstr);
			id.style.display = "";
		}
	}
	else
	{
		id = document.getElementById(id_str1);
		id.style.borderTop = "1px solid #CECDCD";
		id = document.getElementById(id_str2);
		id.style.borderBottom = "1px solid #CECDCD";
		id = document.getElementById(id_str3);
		id.style.borderLeft = "1px solid #CECDCD";
		id.style.borderRight = "1px solid #CECDCD";
		
		for(i = 0; i < 4; i++)
		{
			idstr = bimages[i] + num;
			id = document.getElementById(idstr);
			id.style.display = "";
			idstr = bimages[i] + "_red" + num;
			id = document.getElementById(idstr);
			id.style.display = "none";
		}
	}
}

function showCatReviews(id)
{
	var rsection = document.getElementById(id);
	rsection.style.display = '';
}

function hideCatReviews(id)
{
	var rsection = document.getElementById(id);
	rsection.style.display = 'none';
}

function SetCookieForNDays(name, value, days, path, domain, secure)
{
	var today = new Date();
	expires = new Date(today.getTime() + days * 24 * 60 * 60 * 1000);
	document.cookie = name + "=" + escape(value) +
                "; expires=" + expires.toGMTString() +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "");
}

function GetCookie(name) 
{
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length))) 
	{
		return null;
	}
	if (start == -1) 
	{
		return null;
	}
	var end = document.cookie.indexOf(";", len);
	if (end == -1)
	{
		end = document.cookie.length;
	}
	
	return unescape(document.cookie.substring(len,end));
}

function showTopProducts(url)
{
    var cookieValue = GetCookie("top_product");
    if(!cookieValue)
    {
        SetCookieForNDays("top_product", 1, 1);
        
        popunder = window.open(url, "top_products", "menubar=no, height=660, width=717");
        popunder.blur();
        window.focus();
    }
}

function modifyBrandSectionTimer()
{
	var timer = setTimeout("modifyBrandSection()", 5000);
}

function modifyBrandSection()
{
	if(block = document.getElementById("brand-section"))
	{
		block.style.display = "";
	}
	if(block = document.getElementById("price-message-first"))
	{
		block.style.display = "";
	}
	if(block = document.getElementById("price-message-second"))
	{
		block.style.display = "none";
	}
}

function showSection(id)
{
	var elem;
	
	if (elem = document.getElementById(id))
	{
		if(elem.style.display == "none")
		{
			elem.style.display = "";
		}
		else
		{
			elem.style.display = "none";
		}
	}
}

function getURL(url)
{
    if (window.XMLHttpRequest)
    {
	    request = new XMLHttpRequest();
    }
    else
    {
	    if (window.ActiveXObject)
	    {
		    try
		    {
			    request = new ActiveXObject("Msxml2.XMLHTTP");
		    }
		    catch (e)
		    {
			    try
			    {
				    request = new ActiveXObject("Microsoft.XMLHTTP");
			    }
			    catch (e)
			    {
			    }
		    }
	    }
    }

    if (request)
    {
	    request.open("GET", url, false);
	    request.send(null);
	    if (request.status == 200)
	    {
		    var data = request.responseText;
		    return data;
	    }
    }
}


function voteReview(root, id, vote, keyword)
{
	url = root + "support/vote_review.php?id=" + escape(id) + "&vote=" + escape(vote) + "&keyword=" + escape(keyword);
	getURL(url);

	document.getElementById('r_' + id + '_thanks').style.display = 'block';
}

function checkContactForm(root)
{	
	var error = false;
	var error_msg = "";

	if (document.getElementById('c_name').value == "")
	{
		error = true;
		error_msg = "Please enter Your Name.\r\n";
	}
	if (document.getElementById('c_email').value == "")
	{
		error = true;
		error_msg += "Please enter Email Address.\r\n";
	}	
	if (document.getElementById('c_message').value == "")
	{
		error = true;
		error_msg += "Please enter Comment/Question.\r\n";
	}	
	if (document.getElementById('c_captcha').value == "")
	{
		error = true;
		error_msg += "Please enter Letters/numbers you see on the image.\r\n";
	}
	else
	{
		url = root + "support/captcha_check.php?captcha=" + escape(document.getElementById('c_captcha').value);				
		data = getURL(url);		
		if (data != "Captcha is correct")
		{
			error = true;	
			error_msg += "Please enter correct Letters/numbers you see on the image.\r\n";
		}
	}	

	if (error)
	{
		alert(error_msg);
		return false;
	}

	//document.getElementById('c_button').style.display = "none";
	return true;
}
