// JavaScript Document
<!--
function testAlert()
{
		alert('here I am, testing the alert function in allscripts.php');
}
//Macromedias jump menu script
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function setCookie($cookieName, $cookieValue, $expire)
{
	var expiry = new Date();
	if($expire == 'y')
	{
		expiry.setTime( expiry.getTime() - (24*60*60*1000))	
	}
	else
	{
		expiry.setTime( expiry.getTime() + (24*60*60*1000))	
	}
	window.document.cookie = $cookieName+"="+$cookieValue+";"+"expires="+expiry.toGMTString()+";";
	//alert('cookie value = '+$cookieValue);
}
//empty variable to store window object
var popwin = null;
//function to open popup
function open_popup(prodnum)
{
	if(popwin == null)
	{
		var url="shopping-add-review.php?prodnum="+prodnum;
		popwin = window.open(url);
	}
}
function price_guarantee_popup(prodName)
{
	var url="popups/lowest-price-guarantee.php?prodName="+prodName;
	thing = window.open(url, "", "width=570, height=500");
}

function close_popup()
{
	if(popwin != null)
	{
	alert('here it is');
		popwin.close(); popwin = null;
	}
}
function ratingStarRollover(property,number)
{
	var hiddenId = 'hidden'+property;
	if(window.document.getElementById(hiddenId).value ==0)
	{
		for(var i = 1; i<=number; i++)
		{
			var tempId = property+i;
			window.document.getElementById(tempId).src = 'images/rating_star.gif';
		}
	}
}
function ratingStarRollout(property,number)
{
	var hiddenId = 'hidden'+property;
	if(window.document.getElementById(hiddenId).value ==0)
	{
		for(var i = 1; i<=number; i++)
		{
			var tempId = property+i;
			window.document.getElementById(tempId).src = 'images/rating_star_grey.gif';
		}
	}
}
function ratingStarSet (property,number)
{
	var hiddenId = 'hidden'+property;
	//alert (hiddenId);
	window.document.getElementById(hiddenId).value = number;
	for(var i = 1; i<=5; i++)
	{
		var tempId = property+i;
		if(i<=number)
		{
			window.document.getElementById(tempId).src = 'images/rating_star.gif';		
		}
		else
		{
			window.document.getElementById(tempId).src = 'images/rating_star_grey.gif';		
		}
	}
}
function showHidden (id)
{
	alert('here I am in showHidden');
	var val = window.document.getElementById(id).value;
	alert(val);
}
function changeHidden(toId, fromId)
{
	alert('here I am in changeHidden');
	//fromId = place to take value from, toId = place to put value
	window.document.getElementById(toId).value = window.document.getElementById(fromId).value;
}
function validateReviewForm()
{
	var validated = 0;
	var name, review, hiddenq, hiddenv, hiddenc;
	if(window.document.getElementById(name).value != ''){validated++; name = 1}else{name = 0;}
	if(window.document.getElementById(review).value != ''){validated++; review =1;}else{review = 0;}
	if(window.document.getElementById(hiddenq).value >0){validated++; hiddenq =1;}else{hiddenq = 0;}
	if(window.document.getElementById(hiddenv).value >0){validated++; hiddenv =1;}else{hiddenv = 0;}
	if(window.document.getElementById(hiddenc).value >0){validated++; hiddenc =1;}else{hiddenc = 0;}
	
	alert ('name = '+name+' - review = '+review+' - hiddenq ='+hiddenq,' - hiddenv = '+hiddenv+' - hiddenc = '+hiddenc+' - validated = '+validated);
	return false
}
function makeRequest(url, parameters, myfunc) {
	//alert('alert from scripts.js 672 '+url+' - '+parameters+' - ');

    var http_request;
    
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
    }
    if (!http_request) {
            alert('AJAX - Giving up :( Cannot create an XMLHTTP instance');
            return false;
    }
	http_request.onreadystatechange = function(){
           
            if (http_request.readyState == 4) {
    //alert('696 '+http_request.readyState);
                if(http_request.status && http_request.status == 200) {                   
                    // Call return function
                    myfunc(http_request.responseText);                                               
                } 
                else {
                    alert('706 There is a problem with AJAX, please contact support. Error: 706 - http_request.status = '+http_request.status+'\n'+url);
                }
            }  
    };           

    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
	//alert('alert from scripts.js 716 '+url+' - '+parameters);
      
}//-->