/*ddsmoothmenu.init({
	mainmenuid: "nav-menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})*/
$(function() {
	$('#ImageGallery a').lightBox();
});

function swf(src, w, h)
{
	html = '';
	html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="param" width="'+w+'" height="'+h+'">';
	html += '<param name="movie" value="'+src+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="wmode" value="transparent">';
	html += '<embed wmode="transparent" src="'+src+'" quality=high bgcolor="" width="'+w+'" height="'+h+'" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	html += '<\/object>';
	document.write(html);
}

function ValidateCareerForm()
{
	with(document.CareerForm)
	{
		if(Name.value=='')
		{
			alert("ErrorMsg", "Please enter your name", Name);
			return false;
		}
		else if(Email.value=='')
		{
			alert("ErrorMsg", "Please enter your email address", Email);
			return false;
		}
		else if(isEmail(Email.value)==false)
		{
			alert("ErrorMsg", "Please enter your email address in correct format", Email);
			return false;
		}
		else if(Gender.value=='-1')
		{
			alert("ErrorMsg", "Please select your gender", Gender);
			return false;
		}
		else if(MartialStatus.value=='-1')
		{
			alert("ErrorMsg", "Please select your martial status", MartialStatus);
			return false;
		}
		else if(MartialStatus.value=='0')
		{
			alert("ErrorMsg", "Please select your marital status", MartialStatus);
			return false;
		}
		else if(Phone.value=='')
		{
			alert("ErrorMsg", "Please enter your phone number", Phone);
			return false;
		}
		else if(BirthDate.value=='')
		{
			alert("ErrorMsg", "Please select your birth date", BirthDate);
			return false;
		}
		else if(Nationality.value=='-1')
		{
			alert("ErrorMsg", "Please select your nationality", Nationality);
			return false;
		}
		else if(CountryOfResidence.value=='-1')
		{
			alert("ErrorMsg", "Please select your country of residence", CountryOfResidence);
			return false;
		}
		else if(Education.value=='')
		{
			alert("ErrorMsg", "Please enter your education", Education);
			return false;
		}
		else if(Post.value=='')
		{
			alert("ErrorMsg", "Please enter post, you want to apply", Post);
			return false;
		}
		else if(Experience.value=='')
		{
			alert("ErrorMsg", "Please enter your experience", Experience);
			return false;
		}
		else if(VisaStatus.value=='-1')
		{
			alert("ErrorMsg", "Please select visa status", VisaStatus);
			return false;
		}
		else if(Resume.value=='')
		{
			alert("ErrorMsg", "Please upload your resume", Resume);
			return false;
		}
		else if(CheckExtension(Resume.value)!='doc' && 
		CheckExtension(Resume.value)!='docx')
		{
			alert("ErrorMsg", "Only doc or docx files Allowed");
			Resume.focus();
			return false;
		}
		else if(AboutMe.value=='')
		{
			alert("ErrorMsg", "Please write something about yourself", AboutMe);
			return false;
		}
		ValidateCareerFormFlag.value='true';
	}
	return true;
}


function ValidateContactForm()
{
	with(document.ContactForm)
	{
		if(Name.value=='')
		{
			alert("ErrorMsg", "Please enter your name", Name);
			return false;
		}
		else if(Email.value=='')
		{
			alert("ErrorMsg", "Please enter your email address", Email);
			return false;
		}
		else if(isEmail(Email.value)==false)
		{
			alert("ErrorMsg", "Please enter your email address in correct format", Email);
			return false;
		}
		else if(Phone.value=='')
		{
			alert("ErrorMsg", "Please enter your phone number", Phone);
			return false;
		}
		else if(Message.value=='')
		{
			alert("ErrorMsg", "Please enter your message", Message);
			return false;
		}
		ValidateContactFormFlag.value='true';
	}
	return true;
}

function alert(Type, txtMsg, FocusElement)
{
	if(Type=="ErrorMsg")
	{
		var ErrorHTML='<table cellpadding="3" cellspacing="0" border="0"><tr><td align="center" valign="top"><img src="images/error_icon_small.png" alt="" /></td><td align="left" valign="top"><span style="font-size:13px;">'+txtMsg+'</span></td></tr></table>';
		$.prompt(ErrorHTML, {buttons: {Ok:true}});
	}
	else if(Type=="ErrorMsg2")
	{
		var ErrorHTML='<table cellpadding="3" cellspacing="0" border="0"><tr><td align="center" valign="top"><img src="images/confirm_icon.png" alt="" /></td><td align="left" valign="top"><span style="font-size:13px;">'+txtMsg+'</span></td></tr></table>';
		$.prompt(ErrorHTML, {buttons: {Ok:true}});
	}
	else
	{
		$.prompt(txtMsg, {buttons: {Ok:true}});
	}
	$('#jqi').css({'width': '350px', 'left': '50%', 'margin-left': '-183px'});
	$('.jqimessage').css({'text-align':'center', 'color':'#0a0a0a', 'font-weight':'bold', 'font-size':'15px'});
	
	if(FocusElement!='')
	{
		$('#impromptu_state0_buttonOk').click(function(){
			$('#jqi').fadeOut(function(){
				$('#jqibox').remove();
			});
			FocusElement.focus();
		});
		
		$('#jqi_state0_buttonClose').click(function(){
			$('#jqi').fadeOut(function(){
				$('#jqibox').remove();
			});
			FocusElement.focus();
		});
		
		$('#jqi_state0_buttonOk').click(function(){
			$('#jqi').fadeOut(function(){
				$('#jqibox').remove();
			});
			FocusElement.focus();
		});
	}
}

function isEmail(theStr) 
{
	var atIndex = theStr.indexOf('@');
 	var dotIndex = theStr.indexOf('.', atIndex);
 	var flag = true;
 	theSub = theStr.substring(0, dotIndex+1)
 	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
 	{	 
 		flag = false; 
 	}
 	else 
	{ 
 		flag = true; 
 	}
 	return(flag);
}

function numbersonly(e, decimal)
{
	var key;
	var keychar;
	
	if(window.event)
	{
		key = window.event.keyCode;
	}
	else if(e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	keychar = String.fromCharCode(key);
	
	if((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
	{
		return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1))
	{
		return true;
	}
	/*else if (decimal && (keychar == ".")) {*/ 
	else if (decimal)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function CheckExtension(filename)
{
	var parts = filename.split('.');
	var extension = parts[parts.length-1];
	return extension.toLowerCase();
}
