//get page name
function menuSel(pagename,pageid) {
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	if(sPage == pagename)
		document.getElementById(pageid).className = "sel";
	if(sPage == '')
		document.getElementById(pageid).className = "sel";
	
	//current date display
	var theDate=new Date();
	document.getElementById('currentDate').innerHTML = theDate.getFullYear();
}

//show alert msg
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function getpara() { 
	var frank_param = gup( 'succ' );
	if(frank_param == 1)
		document.getElementById('showmsg').style.display = 'inline';
		
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	document.getElementById('pagename').value = sPage;
}

//random string
function randomString(length) { 
    var chars = '23456789abcdefghjkmnpqrstuvwxtz'.split('');
    
    if (! length) {
        length = Math.floor(Math.random() * chars.length);
    }
    
    var str = '';
    for (var i = 0; i < length; i++) {
        str += chars[Math.floor(Math.random() * chars.length)];
    }
	document.getElementById('capcha_quote').value = str;
}

function validatetest() {
	var e=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,4}$/;
	if(document.frmquote.name_quote.value == ''){
		alert('Enter the name');
		document.frmquote.name_quote.focus();
		return false;
	}
	if(document.frmquote.email_quote.value == ''){
		alert('Enter the email id');
		document.frmquote.email_quote.focus();
		return false;
	}
	if(!document.frmquote.email_quote.value.match(e)) {
		alert("Enter valid Email Address");
		document.frmquote.email_quote.select();
		return false;
	}
	if(document.frmquote.desc_quote.value == ''){
		alert('What are you looking to create');
		document.frmquote.desc_quote.focus();
		return false;
	}
	if(document.frmquote.user_capcha_quote.value == ''){
		alert('Enter the text shown in near');
		document.frmquote.user_capcha_quote.focus();
		return false;
	}
	if(document.frmquote.user_capcha_quote.value != document.frmquote.capcha_quote.value){
		alert('Please check the capcha code');
		document.frmquote.user_capcha_quote.focus();
		return false;
	}
}

function validateapplynow(){
	var	char_num="0123456789";
	var regMail = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/;
	if(document.forms.frmapplynow.yourname.value == "") {
		alert('Enter your name');
		document.forms.frmapplynow.yourname.focus();
		return false;
	}
	if(document.forms.frmapplynow.youremail.value == "") {
		alert('Enter the email number');
		document.forms.frmapplynow.youremail.focus();
		return false;
	}
	if(regMail.test(document.forms.frmapplynow.youremail.value) == false) {
		alert('Enter the valid email number');
		document.frmapplynow.youremail.select();
		return false;
	}
	if(document.forms.frmapplynow.mobileno.value != "") {
		for (var i=0; i<document.forms.frmapplynow.mobileno.value.length; i++) {
	        if (char_num.indexOf(document.forms.frmapplynow.mobileno.value.charAt(i)) < 0) {
	            alert('Enter the valid phone number');
				document.forms.frmapplynow.mobileno.select();
		        return false;
		    }
		}
	}
	if(document.forms.frmapplynow.cv.value == "") {
		alert('Upload your resume');
		document.forms.frmapplynow.cv.focus();
		return false;
	}
	if(document.forms.frmapplynow.cv.value != "") { 
		var ext = document.forms.frmapplynow.cv.value.substr(document.forms.frmapplynow.cv.value.lastIndexOf('.') + 1);
		if(ext != 'doc' && ext != 'docx' && ext != 'pdf') {
			alert('Please upload doc,docx or pdf format file only');
			return false;
		}
	}
	if(document.forms.frmapplynow.user_capcha_quote.value == "") {
		alert('Enter the capcha');
		document.forms.frmapplynow.user_capcha_quote.focus();
		return false;
	}
	if(document.forms.frmapplynow.user_capcha_quote.value != document.forms.frmapplynow.capcha_quote.value){
		alert('Please check the capcha code');
		document.forms.frmapplynow.user_capcha_quote.select();
		return false;
	}
}



