function searchBoxFocus(evtType) {
    var evt = new Event(evtType);
    var defaultTxt = $("defaultKeywords").value;
    if (evt.type == "focus" && this.value == defaultTxt) {
        this.value = "";
    } else if (evt.type == "blur" && trimWhitespace(this.value) == "") {
        this.value = defaultTxt;
    }
}

/********** Global Utility functions ************/

function trimWhitespace(val) {
return val.replace(/^[ \t]+|[ \t]+$/g, '');
}

function trimAllWhitespace(val) {
 return val.replace(/\s+/g, '');
}

function validEmail(emailAddress) {
 var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
 return emailAddress.match(emailExp);
}

function validateForm(fldsArray) {
var passed = true;

 fldsArray.each(function(item, index){
 var itemInvalid;
 switch(item.get('tag')) {
 case "select":
 itemInvalid = item.selectedIndex == 0;
 break;
 default:
 //if (item.getProperty('type') == 'checkbox')
 // return item.checked;
 itemInvalid = trimWhitespace(item.value).length == 0;
 }
 if (itemInvalid && !item.hasClass('fieldError'))
 item.addClass('fieldError');
 else if (!itemInvalid)
 item.removeClass('fieldError');

 passed = itemInvalid ? false : passed;
 });

 return passed;
}


function getBrowserName()
{
	var lsBrowser = navigator.userAgent;
	if (lsBrowser.indexOf('MSIE') >= 0)
	{
		lsBrowser = 'MSIE';
	}
	else if (lsBrowser.indexOf('Netscape') >= 0)
	{
		lsBrowser = 'Netscape';
	}
	else if (lsBrowser.indexOf('Firefox') >= 0)
	{
		lsBrowser = 'Firefox';
	}
	else if (lsBrowser.indexOf('Safari') >= 0)
	{
		lsBrowser = 'Safari';
	}
	else if (lsBrowser.indexOf('Opera') >= 0)
	{
		lsBrowser = 'Opera';
	}
	else
	{
		lsBrowser = 'UNKNOWN';
	}
	
	return lsBrowser;
}

function getBrowserVersion()
{
	var findIndex;
	var browserVersion = 0;
	var browser = getBrowserName();
		browserVersion = navigator.userAgent;
		findIndex = browserVersion.indexOf(browser) + browser.length + 1;
		browserVersion = parseFloat(browserVersion.substring(findIndex,findIndex + 3));
		
	return browserVersion;
}


function ValidBrowser(){
	var browserName = getBrowserName();
	var browserVersion = getBrowserVersion();
	if (browserName == 'MSIE')
	{
		if (browserVersion < 7.0)
		{
			document.location = "error.htm"
		}
		else
		{
			document.location = "main.htm"
		}
	}
	else if (browserName == 'Firefox')
	{
			document.location = "main.htm"		
	}
    else if (browserName == 'Safari')
    {
			document.location = "main.htm"
    }		
	else if (browserName == 'Netscape')
	{
			document.location = "main.htm"
	}
	else
	{
	}
}


function checkportfolio(){
	var browserName = getBrowserName();
	var browserVersion = getBrowserVersion();
	
	if (browserName == 'MSIE')
	{
		document.location = "portfolioie.htm"
	}
	else
	{
		document.location = "portfolioun.htm"
	}
}


function random_div(){

	var mydiv = new Array()
	mydiv[1]="<div><h2>Spotlight</h2><span class='name'>Mustafa Hasnain</span><br /><span class='titleex'>CEO / Creative Director</span><br /><br /><br /><span class='spotlighttext'>Mustafa has a Masters degree in Media	and Communication from the London School of Economics (LSE) and has almost five years of experience in the field of media<br /><br />He has worked as a 3d animator, web designer, creative consultant and project manager for many multinational organisations such as Nestle and ICWFD. His previous role was of a Creative Director in Sixth Sense, a creative new media company. </span></div>"
	mydiv[2]="<div><h2>Spotlight</h2><span class='name'>Maaz Zahid</span><br /><span class='titleex'>Chief Operating Officer</span><br /><br /><br /><span class='spotlighttext'>Maaz is a business and technology major from the Curtin Business School and has over seven years of experience in business development, digital media & advertising.<br /><br />He has consulted on the strategic business development and set up of an innovative educational initiative - the Discovery Centre and a progressive sports brand Rage &reg; Hockey. He has also been involved in formulating, aiding and executing business expansion strategies for UNIDO, Mobilink and other renowned corporations.</span></div>"
	mydiv[3]="<div><h2>Spotlight</h2><span class='name'>Pawail Qaisar</span><br /><span class='titleex'>Chief Technology Officer</span><br /><br /><br /><span class='spotlighttext'>Pawail is a Computer Science major from the National University of Computer and Emerging Sciences Lahore, and has over eight years of experience in Web Site and Software Development with expertise in a host of technologies including .net, Java, Flash and PHP.<br /><br />He has previously worked with Sixth Sense, a creative new media company, as a Web Developer.<br /><br />In his spare time, Pawail enjoys music, art films and dining out.</span></div>"

	var ry = Math.floor(Math.random() * mydiv.length)

	if (ry == 0)
		ry = 1
		document.write(mydiv[ry])		
	}


