function showListType1(num)
{
	var navSectionName = new Array();
	navSectionName[1] = "price-section-link";
	navSectionName[2] = "review-section-link";
	navSectionName[3] = "spec-section-link";
	
	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]);
			id.className = "active";
			id = document.getElementById(sectionName[i]);
			id.style.display = "";
		}
		else
		{
			id = document.getElementById(navSectionName[i]);
			id.className = "";
			id = document.getElementById(sectionName[i]);
			id.style.display = "none";
		}
	}
	
	return 0;
}

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 sendContactForm(frm, root)
{
	var isNameCorrect    = true;
	var isEmailCorrect   = true;
	var isCommentCorrect = true;
	var isCaptchaCorrect = true;
	
	var fields = new Array();
	var errors = new Array();
	fields["name"]     = "name-field";
	errors["name"]     = "this information is required";
	fields["email"]    = "email-field";
	errors["email"]    = "please enter valid address";
	fields["comments"] = "comments-field";
	errors["comments"] = "this information is required";
	fields["captcha"]  = "captcha-field";
	errors["captcha"]  = "please try again";
	
	if (frm.name.value == "")
	{
		isNameCorrect = false;
	}
	if (frm.email.value == "" || !(/^[^@]+@[^@\.]+\.[^@]+$/.test(frm.email.value)))
	{
		isEmailCorrect = false;
	}
	if (frm.comments.value == "")
	{
		isCommentCorrect = false;
	}
	if (frm.captcha.value.toLowerCase() != getURL(root + "support/captcha_current.php"))
	{
		isCaptchaCorrect = false;
	}
	
	if (isNameCorrect && isEmailCorrect && isCommentCorrect && isCaptchaCorrect)
	{
        data = getURL(root + "support/contact.php?name=" + escape(frm.name.value) + "&email=" + escape(frm.email.value) + "&comments=" + escape(frm.comments.value));
        
        var obj = document.getElementById("error-message");
		obj.innerHTML = '<b style="color: #1585db;">Thank you for your enquiry. We will endeavour to respond as soon as possible.<br><br></b>';
        
        frm.name.value = "";
        frm.email.value = "";
        frm.comments.value = "";
        frm.captcha.value = "";
		
		clearField(fields["name"]);
		clearField(fields["email"]);
		clearField(fields["comments"]);
		clearField(fields["captcha"]);
	}
	else
	{
		var obj = document.getElementById("error-message");
		obj.innerHTML = '<b style="color: #ff0000;">Please check the errors below and try again.<br><br></b>';
		
		showFieldStatus(fields["name"], errors["name"], isNameCorrect, root);
		showFieldStatus(fields["email"], errors["email"], isEmailCorrect, root);
		showFieldStatus(fields["comments"], errors["comments"], isCommentCorrect, root);
		showFieldStatus(fields["captcha"], errors["captcha"], isCaptchaCorrect, root);
	}
}

function showFieldStatus(id, error, field_status, root)
{
	var imgs = new Array();
	imgs["ok"]        = new Image;
	imgs["ok"].src    = root + "images/ok_img.gif";
	imgs["error"]     = new Image;
	imgs["error"].src = root + "images/error_img.gif";
	
	var obj = document.getElementById(id);
	if (field_status)
	{
		obj.innerHTML = '<img src="' + root + 'images/ok_img.gif" width="22" height="21">';
	}
	else
	{
		obj.innerHTML = '<img src="' + root + 'images/error_img.gif" width="22" height="22" style="float: left;">&nbsp;&nbsp;' + error;
	}
}

function clearField(id)
{
    var obj = document.getElementById(id);
    obj.innerHTML = '';
}

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 openWindow(url)
{
	window.open(url, "_blank");
}

function showSection(id)
{
	var elem;
	
	if (elem = document.getElementById(id))
	{
		if(elem.style.display == "none")
		{
			elem.style.display = "";
		}
		else
		{
			elem.style.display = "none";
		}
	}
}

function showContactForm(upPixels)
{
    showGreyLayer();
    
	idForm = document.getElementById("jsiMainBox");
	idForm.style.left = (document.body.clientWidth / 2 - 375) + "px";
	idForm.style.top = (document.body.clientHeight / 2 - upPixels) + "px";

	idForm.style.display = '';
}

function changeAllSelectDisabled(vis)
{
	var coll = document.all.tags("SELECT");
	if (coll.length > 0)
	{
		for (i = 0; i < coll.length; i++)
		{
			coll.item(i).style.visibility = vis;
		}
	}
}

function showGreyLayer()
{
    idSpacer = document.getElementById("divSpacer");
	id_flow = document.getElementById("wrapJsiBox");
    
    if (document.body.clientHeight > (idSpacer.offsetTop + 10))
    {
        id_flow.style.height = document.body.clientHeight;
    }
    else
    {
        id_flow.style.height = idSpacer.offsetTop + 10;
    }
    
    //[pageWidth,pageHeight,windowWidth,windowHeight] = getPageSize();
    
    id_flow.style.height = getPageSize() + "px";
    //id_flow.style.height = "1000px";
	id_flow.style.display = '';
    
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		changeAllSelectDisabled("hidden");
	}
}

function hideGreyLayer()
{
	id_flow = document.getElementById("wrapJsiBox");
	id_flow.style.display = 'none';
    
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		changeAllSelectDisabled("visible");
	}
}

function closeContactForm()
{
    idForm = document.getElementById("jsiMainBox");
	idForm.style.display = 'none';
    
    obj = document.getElementById("error-message");
    obj.innerHTML = '<b>&nbsp;</b>';
    
    hideGreyLayer();
}

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 if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in 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;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	//return [pageWidth,pageHeight,windowWidth,windowHeight];
	return pageHeight;
}

