// JavaScript Document for TCPOWER 

doWindowClose=function()
	{
		
		var links=document.getElementsByTagName('a');
		for (x=0;x<links.length;x++)
			{
				
				if (links[x].className.indexOf('close') != -1)
					{
							links[x].onclick=function()
								{
										if (this.getAttribute("title")== "Go back")
										{
										var formwindow=window.open("http://www.tcpower.co.uk/distibuterenquiry.html", "form",
					"width=400,height=400,resizable");
						 if (formwindow)
						 {
							
							
						  if (formwindow.open) {
									formwindow.close;
							 }
								formwindow.focus();
								formwindow.document.write(writeJS(this.getAttribute("rev"),location.href));
								formwindow.document.close();
								return false;
		 }
										}
										else
										{
										 window.parent.location.href=this.getAttribute("href");								window.close();
										}
								}
					}
			}
	}
	
doPopups=function () {
	if(!document.getElementById('gen_nav')) return false;
		var genid=document.getElementById('gen_nav');
var imgtags=genid.getElementsByTagName('img');

for (x=0;x<imgtags.length;x++)
	{
     	imgtags[x].onclick = function() {
		
		 var formwindow=window.open("http://www.tcpower.co.uk/distibuterenquiry.html", "form",
    "width=400,height=400,resizable");
		 if (formwindow)
		 {
			
			
		  if (formwindow.open) {
					formwindow.close;
		     }
		  		formwindow.focus();
           		formwindow.document.write(writeJS(this.getAttribute("alt"),location.href));
				formwindow.document.close();
		 }
			

          return false;   
        }
	}
 }

doaenquiry=function()
{
	if(!document.getElementById('makeenquiry')) return false;
var link=document.getElementById('makeenquiry');


     	link.onclick = function() {
		 var formwindow=window.open("../distibuterenquiry.html", "form",
    "width=400,height=400,resizable");
		 if (formwindow)
		 {
			
			
		  if (formwindow.open) {
					formwindow.close;
		     }
		  		formwindow.focus();
           		formwindow.document.write(writeJS(this.getAttribute("title"),location.href));
				formwindow.document.close();
		 }
			

          return false;   
        }
	
 }	
function writeJS(imgalt,url){
var str='';
str+="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
str+="<html>";
str+="<head>";
str+="<title>TC Power Ltd - make an Enquiry<\/title>";
str+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";

str+="<link href=\"http://www.tcpower.co.uk/tcpower_form.css\" rel=\"stylesheet\" type=\"text/css\">";
str+="<\/head>";

str+="<body>";
str+="<br /><form action=\"http://www.tcpower.co.uk/generators/makeenquiry.php\" method=\"post\" name=\"myform\" id=\"myform\" >";
str+="<fieldset class=\"bg\">";
str+="	<legend>Your Enquiry<\/legend>";
str+="	<p><label for=\"Name\">Name<\/label><input name=\"name\" type=\"text\" id=\"name\" size=\"25\" class=\"required\"/>";
str+="	<\/p>";
str+="	<p><label for=\"Telephone\">Tel<\/label><input name=\"telephone\" type=\"text\" id=\"telephone\" size=\"25\" class=\"required\" />";
str+="	<\/p>";
str+="	<p><label for=\"Email\">Email<\/label><input name=\"email\" type=\"text\" id=\"email\" size=\"25\" class=\"email\"/>";
str+="	<\/p>";
str+="	<p><label for=\"Enquiry\">Enquiry<\/label><textarea name=\"enquiry\" cols=\"25\" rows=\"5\" id=\"enquiry\" class=\"required\" />I am enquiring about "+ imgalt +"<\/textarea>";
str+="	<\/p>";
str+="	<p align=\"center\"><input type=\"hidden\" name=\"referrer\" id=\"referrer\" value=\""+url+"\" /><input name=\"submit\" type=\"submit\" value=\"Submit\"><\/p><br/>";
str+="<\/fieldset>";
str+="<\/form>";
str+="<\/body>";
str+="<\/html>";
return(str);
}

//-->
// initiation code adopted ffrom J Keith DOM Scripting
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
addLoadEvent(doPopups);
addLoadEvent(doWindowClose);
addLoadEvent(doaenquiry);
