// JavaScript Document
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;


function importXML(xml_file)
{
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = createTable;
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) createTable()
		};
 	}
	else
	{
		alert('Your browser can\'t handle this script');
		return;
	}
	xmlDoc.load(xml_file);
}


function changeClass(obj) {	
	obj.className = "on";
	portThumbs = document.getElementById("portThumbs");
	thumb = portThumbs.getElementsByTagName("a");
	for (i=0;i< thumb.length;i++) {
		if (thumb != obj) {
			thumb.className = "";
		}
	}
	
	
}



function validateContactForm(form) {
	name    = form.name.value;
	email   = form.email.value;
	subject = form.subject.value;
	message = form.message.value;
	
	if (name == "") {
		alert("Please enter a name!");
		return false;
	}
	
	if (email == "") {
		alert("Please enter an email address!");
		return false;
	} else {		
	///^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
		var emailRegxp = /^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$/
		if (emailRegxp.test(email) != true) {			
			alert("Please enter a valid email address");			
			return false;
		}
	}
	
	if (subject == "") {
		alert("Please enter a subject!");
		return false;
	}
	
	if (message == "") {
		alert("Please enter a message!");
		return false;
	}
}

function validateRadio(id) {
	checked_radio = -1;
	
	for (i=0;i<document.forms[0]['id'].length;i++) {
		if (document.forms[0]['id'][i].checked) {
			checked_radio = i; 		
			alert("checked");
		}		
		alert(id);
	}
	
	
	if (checked_radio == -1) {		
		return false;
	}
}


function validateEstimateForm(form) {
	name    	   = form.name.value;
	email   	   = form.email.value;	
	website_status = form.website_status.value;
	website_type   = form.website_type.value;
	website_func   = form.website_func.value;
	budget	 	   = form.budget.value;
	
	if (name == "") {
		alert("Please enter a name!");
		return false;
	}
	
	if (email == "") {
		alert("Please enter an email address!");
		return false;
	} else {		
	///^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
		var emailRegxp = /^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$/
		if (emailRegxp.test(email) != true) {			
			alert("Please enter a valid email address");			
			return false;
		}
	}
	
	//if (!validateRadio(website_status)) {
		//alert("Please specify whether the website is brand new, or whether you would like a re-design!");
		//return false;
	//}

	//if (!validateRadio(website_type)) {
		//alert("Please select whether your website will require dynamic content!");
		//return false;
	//}
	
	if (website_func == "") {
		alert("Please enter a description of what you want your website to do!");
		return false;
	}
	
	if (budget == "") {
		alert("Please enter a budget!");
		return false;
	}
}

function newwindow(url) {
	// Set width and height
	var winWidth = 300;
	var winHeight = 400;
	// Set Window position
	var winTop = 0;
	var winLeft = 0;
	// Set other attributes
	var toolbar = "no";
	var location = "no";
	var directories = "no";
	var status = "no";
	var menubar = "no";
	var scrollbars = "no";
	var resizable = "no";
	var atts="width="+winWidth+",height="+winHeight+",top="+winTop+",screenY="+winTop+",left="+winLeft+", screenX="+winLeft+", scrollbars="+scrollbars+"";
	// open the window
	window.open(url,'',atts);
}

function newwindow_params(url,width,height) {
	// Set width and height
	var winWidth = width;
	var winHeight = height;
	// Set Window position
	var winTop = 0;
	var winLeft = 0;
	// Set other attributes
	var toolbar = "no";
	var location = "no";
	var directories = "no";
	var status = "no";
	var menubar = "no";
	var scrollbars = "no";
	var resizable = "no";
	var atts="width="+winWidth+",height="+winHeight+",top="+winTop+",screenY="+winTop+",left="+winLeft+", screenX="+winLeft+", scrollbars="+scrollbars+"";
	// open the window
	window.open(url,'',atts);
}


function bigimage(image,wid,hgt){
	sw=(screen.width-wid)/2;
	sh=(screen.height-hgt)/2;
	newwin=window.open('','newwin','width='+wid+',height='+hgt+',scrollbars=0,menubars=0,toolbars=0,loca tion=0,directories=0,status=0,top='+sh+',left='+sw+'');
	newwin.document.open();
	newwin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n');
	newwin.document.write('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
	newwin.document.write('\n<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n');
	newwin.document.write('<meta http-equiv="Imagetoolbar" content="no" />\n');
	newwin.document.write('<title></title>\n');
	newwin.document.write('</head>');
	newwin.document.write('<body style="margin:0;padding:0">\n<img src="'+image+'" width="'+wid+'" height="'+hgt+'" />');
	newwin.document.write('\n</body></html>');
	newwin.document.close();
	newwin.focus();
}