  var navWin
  var supplierWin
  var referWin
  var WinName  = "thewindow";
  var HTMLrefresh = '<html><head><META HTTP-EQUIV="Refresh" CONTENT="2; url=default.asp"></head></html>'
  
function moreInfo(thepage,theID){
	openNav("moreinfo.asp",WinName,ScreenProps)
}   
function getreviews(theform,winExtension,action){
  	var ScreenProps = "width=435,height=470,scrollbars,status"
	var res = '<form type="hidden" action="'+action+'" method="post" name="'+theform.name+'">\n'
	for (var i=0; i <theform.length; i++){
		if (theform.floading_time.value == 0){
		alert('loading')
		intervalID2 = setTimeout("getreviews(theform)",200)
		}		
		res += ('<input type="hidden" name="'+theform[i].name+'" value="'+theform[i].value+'">\n')
	}	
	res += '</form>\n'
	//alert(res)
	openNav("",("reviews"+winExtension),ScreenProps)
	supplierWin.document.write(res)
	supplierWin.document.forms[theform.name].submit()
}
function getmorefromreview(theform, revsupplierID){
//alert('1more')
	var res = HTMLrefresh+ '<form type="hidden" action="moreinfo.asp" method="post" name="moreinfo">\n'
//alert('2more')
	if (theform.floading_time.value == 0){
		alert('loading')
		intervalID2 = setTimeout("getmorefromreview(theform)",200)
	}
	for (var i=0; i <theform.length; i++){
		res += ('<input type="hidden" name="'+theform[i].name+'" value="'+theform[i].value+'">\n')
	}	
	res += '</form>\n'
	window.opener.document.write(res)
	window.opener.focus()
	window.opener.document.forms['moreinfo'].submit()
}
function getwritefromreview(theform, revsupplierID){
	var res = '<form type="hidden" action="write_review.asp" method="post" name="write_review">\n'
	if (theform.floading_time.value == 0){
		alert('loading')
		intervalID2 = setTimeout("getwritefromreview(theform)",200)
	}
	for (var i=0; i <theform.length; i++){
		res += ('<input type="hidden" name="'+theform[i].name+'" value="'+theform[i].value+'">\n')
	}	
	res += '</form>\n'
	window.opener.document.write(res)
	window.opener.focus()
	window.opener.document.forms['write_review'].submit()
}
function openNav(page, windowName, ScreenProps) {
	//alert('openNav')
	if(!supplierWin || supplierWin.closed) {
		supplierWin = window.open(page,windowName,ScreenProps);
	}
	else{
		supplierWin.focus();
		supplierWin.location = page ;
	}
}
function opensubmitURL(){
  	var ScreenProps = "width=350,height=195,status"
	var res = '<form action="/submitURL.asp" method="post" name="submitURL">\n'
	for (var i=0; i <submitURL.length; i++){
		if (submitURL.floading_time.value == 0){
		alert('loading')
		intervalID2 = setTimeout("opensubmitURL(submitURL)",200)
		}		
		res += ('<input type="hidden" name="'+submitURL[i].name+'" value="'+submitURL[i].value+'">\n')
	}	
	res += '</form>\n'
	openNav("",("suggestedURL"),ScreenProps)
	supplierWin.document.write(res)
	supplierWin.document.forms['submitURL'].submit()
}
function openreferral(URL, ID) {
	//alert('openreferral')
	//if (!ID)
  	var ScreenProps = "width=435,height=400,scrollbars=1,status=1,location=1,toolbar=1,resizable=1"
	openNav(("/refer.asp?URL="+URL),"referrals",ScreenProps)
}
function openrecommend() {
	//alert('openrecommend')
  	var ScreenProps = "width=350,height=188,status"
	openNav("/recommend.asp","recommendWin",ScreenProps)
}
function openforgotten() {  
	//alert('openrecommend')
  	var ScreenProps = "width=350,height=195,status"
	openNav("/forgotton.asp","forgottenWin",ScreenProps)
}
// Close the navigator
function closeNav() {
	if(navWin) {
		if(!navWin.closed) navWin.close();				
	}
}
function submitform(blah){
 	alert('submitting'+document[blah].fmessagethread.value)
	document[blah].submit()
}
function resetForm(form){
	//alert(form.name)
	document.register.reset(form)
}
 function updateClientData() {
 	var stopTime = new Date();
 	stopTime = stopTime.getTime();
 	var num = ((parseInt(stopTime) - parseInt(startTime)) / 1000 )
 	//alert('update'+stopTime+" "+startTime+" "+ num)
 	//alert(document.forms.length+" ="+document.forms.length)
 	for(f=0;f<document.forms.length;f++){			
 	//alert(document.forms[f].name)		
 	//alert(document.forms[f].elements.length)
 		 document.forms[f].floading_time.value = num + " seconds";
 		 document.forms[f].fpage.value = document.title;
 		 document.forms[f].freferrer.value = document.referrer;
 		 document.forms[f].fplatform.value = navigator.appName  + " " + navigator.appVersion;	
 		 document.forms[f].fscreen_avHeight.value = window.screen.availHeight;
 		 document.forms[f].fscreen_avWidth.value = window.screen.availWidth;
 		 document.forms[f].fscreen_colorDepth.value = screen.colorDepth;
 		 document.forms[f].fWindow_Height.value = getInsideWindowHeight();
 		 document.forms[f].fWindow_Width.value = getInsideWindowWidth();
 	//alert(document.forms[f].fWindow_Width.value);
 	}	
 }
 function getInsideWindowHeight(){
 	if (isNav){
 		return (window.innerHeight) 
 	} else {
 		return (document.body.clientHeight)
 	}
 }
function getInsideWindowWidth(){
	if (isNav){
		return (window.innerWidth) 
	} else {
		return (document.body.clientWidth)
	}
}
//_____________________________validation
function formatDate (thisdate, swingyear){
			//alert("thisdate" +thisdate.value)
	var date=new Date()
	var result=date.fromDateString(thisdate.value,swingyear)
		if (result){
			//valid date, 'date' now contains my date
			thisdate.value=date.getDateString('uk')
			//date.getDateString(format) which takes 'uk', 'ansi', 'dd/mm/yyyy' 
		}else{
			alert("Please enter a date in the specified format")
			thisdate.value=""
			//invalid date, 'date' unaffected (so still current datetime)
		}
}
function unFormatDate (thisdate, swingyear){
	var date=new Date()
	var result=date.fromDateString(thisdate.value,swingyear)
}