
var hostName = 'http://www.talentwatchers.com';
var currentPage = '';


var currentPagePath = '';
var currentPagePathCount = '1';

function onLoadCommonFunction() {
	//MM_preloadImages('http://www.talentwatchers.com/admin_images/slide_right.jpg');
	
}

function popupWindow(path, where, hite, wide){
	if (window.event){ 
		window.event.returnValue = false;   
	}
	var width;
	var height;
	var imgWidth;
	var imgHeight;
	
	if (screen.width<wide){
		width=screen.width-20;
		imgWidth=width-10;
		var windowX = (screen.width-width)/2;
	}
	else{
		var windowX = (screen.width-wide)/2;
		width=wide;
	}

	if (screen.height<hite){
		height=screen.height-70;
		imgHeight=height-20;
		var windowY = (screen.height-height)/2-30;
	}
	else{
		var windowY = (screen.height-hite)/2-10;
		height=hite;
	}

	var rand_no = Math.random();
	var i = Math.round(100*Math.random());
	if(screen.height<hite || screen.width<wide){
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=0,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	else{
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=0,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	props.moveTo(windowX,windowY);
}


if(window.ActiveXObject) {
	try {
		var oHTTP = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch(e) {
		var oHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
} 
else {
	var oHTTP = new XMLHttpRequest();
}


/*******************************************************
For Check User Details
*******************************************************/
function checkUserName(){
	if(document.forms['userRegistration'].elements['user_name'].value==""){
		document.getElementById('textContentHTML').innerHTML = 'Please enter user name.';
		document.getElementById('theLayer').style.visibility = 'visible';	
		return false;
	}
	var userLoginName = document.forms['userRegistration'].elements['user_name'].value;
	var firstName = document.forms['userRegistration'].elements['first_name'].value;
	var lastName = document.forms['userRegistration'].elements['last_name'].value;
	
	checkUser(hostName+'/ajax_call.php?mode=check_username&user_name='+userLoginName+'&first_name='+firstName+'&last_name='+lastName+'');
}

function checkUser(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('textContentHTML').innerHTML = getValue;
			document.getElementById('theLayer').style.visibility = 'visible';
		}
	}
	oHTTP.send(null);
}


function changeUsernameValue(val){
	document.forms['userRegistration'].elements['user_name'].value = val;
	hideMe(); 
	return false;
}

function totalvalue()
{
	if (document.forms['candidate'].elements['fixed_sal'].value != "")
	{
		if (document.forms['candidate'].elements['variable_sal'].value != "")
		{
		
			
		document.forms['candidate'].elements['total'].value = parseFloat (document.forms['candidate'].elements['fixed_sal'].value) + parseFloat (document.forms['candidate'].elements['variable_sal'].value);
		}
		else
		{
			document.forms['candidate'].elements['total'].value  = parseFloat (document.forms['candidate'].elements['fixed_sal'].value);
		}
	}
	
	else
	{
		document.forms['candidate'].elements['total'].value  = '';
	}	
	
}
function join_totalvalue()
{
	if (document.forms['joinus'].elements['fixed_sal'].value != "")
	{
		if (document.forms['joinus'].elements['variable_sal'].value != "")
		{
		
			
		document.forms['joinus'].elements['total'].value = parseFloat (document.forms['joinus'].elements['fixed_sal'].value) + 	parseFloat (document.forms['joinus'].elements['variable_sal'].value) ;
		}
		else
		{
			document.forms['joinus'].elements['total'].value = parseFloat (document.forms['joinus'].elements['fixed_sal'].value)  ;
		}
		
	}
	else
	{
		document.forms['joinus'].elements['total'].value = '';
	}	
	
}

function other_hear(){
	var ID = document.getElementById('hear').value;
	if(ID == 'Others'){
		var getValue = '<br /><input type="text" name="other" value="" class="look"/>';
		document.getElementById('other_know').innerHTML = getValue;
	} else{
		document.getElementById('other_know').innerHTML = "";
	}
}

function checkMemberId(){
	if(document.forms['signin'].elements['memberid'].value==""){
		document.getElementById('memberid_check').innerHTML = 'Please enter Member ID.';
		return false;
	}
	var userMemberId = document.forms['signin'].elements['memberid'].value;
	
	checkMember(hostName+'/ajax_call.php?mode=check_username&user_id='+userMemberId+'');
}

function checkMember(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('memberid_check').innerHTML = getValue;
		}
	} 
	oHTTP.send(null);
}

function checkMembernickname(){
	if(document.forms['signin'].elements['nickname'].value==""){
		document.getElementById('membernickname_check').innerHTML = 'Please enter your nick name.';
		return false;
	}
	var userMembernickname = document.forms['signin'].elements['nickname'].value;
	var length = userMembernickname.length;
	if(length <= 1){
		document.getElementById('membernickname_check').innerHTML = 'Please enter more than 1 characters.';
		return false;
	}
	
	checkMemberneckname(hostName+'/ajax_call.php?mode=check_neckname&user_nickname='+userMembernickname+'');
}

function checkMemberneckname(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('membernickname_check').innerHTML = getValue;
		}
	} 
	oHTTP.send(null);
}

function chkUnchk(formname, allfldnm, fldname){
	    var arrlenth= document.forms[formname].elements[allfldnm].length;
		for(j=0;j<arrlenth;j++){
		var allchk = document.forms[formname].elements[allfldnm][j].checked;
		alert(allchk);
			
			var arrlen = document.forms[formname].elements[fldname].length;	
			//alert(arrlen);
			for(i=0;i<arrlen;i++){
				if(allchk == true){
					if(document.forms[formname].elements[fldname][i].value!='0') {
						document.forms[formname].elements[fldname][i].checked = true;		
					}
				}
				else{
					if(document.forms[formname].elements[fldname][i].value!='0') {
						document.forms[formname].elements[fldname][i].checked = false;
					} 
				}
			}
		}
	}
	
	function open_tr(id){
		 
		if(document.forms['signin'].elements['rcat_'+id].checked == true){
		
			document.getElementById('cat_'+id).style.display='';
			var arrlen = document.forms['signin'].elements['sub_cat_'+id].length;
			for(i=0;i<arrlen;i++){ 
				document.forms['signin'].elements['sub_cat_'+id][i].checked = true;
			}
		} else {
			var arrlen = document.forms['signin'].elements['sub_cat_'+id].length;
			for(i=0;i<arrlen;i++){ 
				document.forms['signin'].elements['sub_cat_'+id][i].checked = false;
				document.getElementById('cat_'+id).style.display='none';
			}
		}
		
	}
	
	function userLogin() {
	alert(currentPagePath);
	document.getElementById('user_name_err').innerHTML = '';
	document.getElementById('user_pass_err').innerHTML = '';
	var chk = 0;

	var userName = document.getElementById('user_name').value;
	var userPass = document.getElementById('user_pass').value;
	if(userName=="" || userName=="User Name"){
		alert('Please, enter login name');
		document.getElementById('user_name').focus();
		chk++;
		return false;
	}
	if(userPass=="" || userPass=="Password"){
		alert('Please, enter password');
		document.getElementById('user_pass').focus();
		chk++;
		return false;
	}
	if(chk == 0){
	document.getElementById('user_login_form_portion').style.display = 'none';
	document.getElementById('user_login_loader_portion').style.display = '';
	returnUserLogin(hostName+'/ajax_call.php?mode=user_login&userName='+userName+'&userPass='+userPass+'');
	
	}
}

function returnUserLogin(page, userLoginName) {

	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				
				if(currentPagePathCount == '2' && currentPagePath == ''){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else if(currentPagePathCount == '2' && currentPagePath == 'index.php'){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else {
					window.location = currentPage;
				}
			}
			else {
				document.getElementById('user_login_form_portion').style.display = '';
				document.getElementById('user_login_loader_portion').style.display = 'none';
				document.getElementById('user_name_err').innerHTML = 'Invalied Member ID or Password';
			}
		}
	}
	oHTTP.send(null);
}


function box_userLogin() {
	document.getElementById('user_name_err').innerHTML = '';
	document.getElementById('user_pass_err').innerHTML = '';
	var chk = 0;

	var userName = document.getElementById('user_name').value;
	var userPass = document.getElementById('user_pass').value;
	if(userName=="" || userName=="User Name"){
		alert('Please, enter login name');
		document.getElementById('user_name').focus();
		chk++;
		return false;
	}
	if(userPass=="" || userPass=="Password"){
		alert('Please, enter password');
		document.getElementById('user_pass').focus();
		chk++;
		return false;
	}
	if(chk == 0){
	document.getElementById('ajax_loader_mail').style.display = '';
	returnBoxUserLogin(hostName+'/ajax_call.php?mode=user_login&userName='+userName+'&userPass='+userPass+'');
	
	}
}

function returnBoxUserLogin(page, userLoginName) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				//window.location = currentPage;
				if(currentPagePathCount == '2' && currentPagePath == ''){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else if(currentPagePathCount == '2' && currentPagePath == 'index.php'){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else {
					window.location = currentPage;
				}
			}
			else {
				document.getElementById('ajax_loader_mail').style.display = 'none';
				document.getElementById('user_name_err').innerHTML = 'Invalied Member ID or Password';
			}
		}
	}
	oHTTP.send(null);
}


function box_header_userLogin() {
	var chk = 0;

	var userName = document.getElementById('user_name_header').value;
	var userPass = document.getElementById('user_pass_header').value;
	if(userName=="" || userName=="User Name"){
		alert('Please, enter login name');
		document.getElementById('user_name_header').focus();
		chk++;
		return false;
	}
	if(userPass=="" || userPass=="Password"){
		alert('Please, enter password');
		document.getElementById('user_pass_header').focus();
		chk++;
		return false;
	}
	if(chk == 0){
		returnBoxHeaderUserLogin(hostName+'/ajax_call.php?mode=user_login&userName='+userName+'&userPass='+userPass+'');
	}
}

function returnBoxHeaderUserLogin(page, userLoginName) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				//window.location = currentPage;
				/*if(currentPagePathCount == '2' && currentPagePath == ''){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else if(currentPagePathCount == '2' && currentPagePath == 'index.php'){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else {
					window.location = currentPage;
				}*/
				
				window.location = 'http://www.talentwatchers.com/myProfile.php';
			}
			else {
				alert('Invalid Member ID or Password');
			}
		}
	}
	oHTTP.send(null);
}

function box_inner_userLogin() {
	
	document.getElementById('user_name_inner_err').innerHTML = '';
	document.getElementById('user_pass_inner_err').innerHTML = '';
	var chk = 0;

	var userName = document.getElementById('user_name_inner').value;
	var userPass = document.getElementById('user_pass_inner').value;
	if(userName=="" || userName=="User Name"){
		alert('Please, enter login name');
		document.getElementById('user_name_inner').focus();
		chk++;
		return false;
	}
	if(userPass=="" || userPass=="Password"){
		alert('Please, enter password');
		document.getElementById('user_pass_inner').focus();
		chk++;
		return false;
	}
	if(chk == 0){
	document.getElementById('ajax_loader_mail').style.display = '';
	returnBoxInnerUserLogin(hostName+'/ajax_call.php?mode=user_login&userName='+userName+'&userPass='+userPass+'');
	
	}
}

function returnBoxInnerUserLogin(page, userLoginName) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				//window.location = currentPage;
				if(currentPagePathCount == '2' && currentPagePath == ''){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else if(currentPagePathCount == '2' && currentPagePath == 'index.php'){
					window.location = 'http://www.talentwatchers.com/myProfile.php';
				} else {
					window.location = currentPage;
				}
			}
			else {
				document.getElementById('ajax_loader_mail').style.display = 'none';
				document.getElementById('user_name_inner_err').innerHTML = 'Invalid Member ID or Password';
			}
		}
	}
	oHTTP.send(null);
}



function delConfirm(path, toDelete){
	if(confirm('Are you sure to delete this '+toDelete+'?')){
		location.href=''+path+'';
	}
	else{
		return false;	
	}
}

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn', 'lyr1', null);
  
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn'); 
}


function open_tr1(id){
		
		if(document.forms['casting_manager'].elements['rcat_'+id].checked == true){
		
			document.getElementById('cat_'+id).style.display='';
			var arrlen = document.forms['casting_manager'].elements['sub_cat_'+id].length;
			for(i=0;i<arrlen;i++){
				//document.forms['casting_manager'].elements['sub_cat_'+id][i].checked = true;
			}
		} else {
			var arrlen = document.forms['casting_manager'].elements['sub_cat_'+id].length;
			for(i=0;i<arrlen;i++){
				document.forms['casting_manager'].elements['sub_cat_'+id][i].checked = false;
				document.getElementById('cat_'+id).style.display='none';
			}
		}
		
	}	

function Disab(val) 
{
	if(val=="low budget")
	{
		document.casting_manager.paymentid.disabled=true;
	}
	else 
	{	
		document.casting_manager.paymentid.disabled=false;
	}

}

function Disab1(val) 
{
	
	if(val=="indi")
	{
		document.casting_manager.time_range.disabled=true;
		document.casting_manager.gmt_range.disabled=true;
	}
	else 
	{	
		document.casting_manager.time_range.disabled=false;
		document.casting_manager.gmt_range.disabled=false;
	}

}

function check_memberset(){
	alert("Please Login For Contact To This Talent");
	return false;
}
function check_memberset_favourite(){
	alert("Please Login For Add This Talent in Your Favourite List");
	return false;
}


function addToFavourite(loginId,userId){
	returnUserfavourite(hostName+'/ajax_call.php?mode=favourite&loginUser='+loginId+'&user='+userId+'');
}

function returnUserfavourite(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				window.location = currentPage;
			}
		}
	}
	oHTTP.send(null);
}

function changeProfileShow(userId){
	returnProfileShow(hostName+'/ajax_call.php?mode=profileShow&user='+userId+'');
}

function returnProfileShow(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				window.location = currentPage;
			}
		}
	}
	oHTTP.send(null);
}

function changeNewsletter(userId){
	returnNewsLetter(hostName+'/ajax_call.php?mode=NewsLetter&user='+userId+'');
}

function returnNewsLetter(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				window.location = currentPage;
			}
		}
	}
	oHTTP.send(null);
}

function url_redirect(){
	location.href='../index.php';
}

function open_box(){
	//document.getElementById('display_login_box').style.display = '';
	document.getElementById('myfavouritsLogin').style.display = '';
	document.getElementById('favourites_login_form').style.display = '';
	document.getElementById('mailHeading').innerHTML = 'Login';
	document.getElementById('theLayer').style.visibility = 'visible';
}

function dis(){
	if(document.cuploadphoto.upload_photo.value != ""){
	document.getElementById('theLayer').style.visibility = 'visible';
	document.getElementById('ajax_loader_mail').style.display = '';
	}
} 
function dis1(){
	if(document.signin.upload_photo.value != ""){
	document.getElementById('theLayer').style.visibility = 'visible';
	document.getElementById('ajax_loader_mail').style.display = '';
	}
}

function dis_video(){
	if(document.uploadvideo.upload_video.value != ""){
	document.getElementById('theLayer').style.visibility = 'visible';
	document.getElementById('ajax_loader_mail').style.display = '';
	}
}


function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent)
		while(1){
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent)
		while(1){
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}
	function find_position(pos){
	var topPosition;
	topPosition = parseInt(findPosY(document.getElementById(pos)));
	leftPosition = parseInt(findPosX(document.getElementById(pos)));
	leftPosition = leftPosition;
	topPosition = topPosition+30;
	resizeDragBox(632, 600, topPosition, leftPosition);
	}
	

function resizeDragBox(boxWidth, titleBoxWidth, topPosition, leftPosition){
	document.getElementById('theLayer').style.top = parseInt(topPosition)+'px';
	document.getElementById('theLayer').style.left = parseInt(leftPosition)+'px';
}

function checksearch()
{
	if(document.casting.search.value == "" )
	{
		document.casting.search.focus();
		alert("Please type something for search");
		return false;
	}	
}

function checksearch1()
{
	if(document.casting1.search.value == "" )
	{
		document.casting1.search.focus();
		alert("Please type something for search");
		return false;
	}	
}

function changeVideo(ID){
	if(ID!=""){
		changeVideoResponse(hostName+'/ajax_call.php?mode=video&id='+ID);
	}
}

function changeVideoResponse(page) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('video_display').innerHTML = getValue;
		}
	}
	oHTTP.send(null);
}

function changeDropdown(){
	
	var ID = document.getElementById('country_region').value;
	if(ID!=""){
		document.getElementById('region_status').innerHTML = '<img src="'+hostName+'/images/loader1.gif" align="absmiddle" alt="Loader" border="0" title="Please Wait" class="changeStatus" />';
		changeDropdownResponse(hostName+'/ajax_call.php?mode=country&id='+ID);
	}
}

function changeDropdownResponse(page) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('region_status').innerHTML = getValue;
		}
	}
	oHTTP.send(null);
}

function changeDropdown1(){
	
	var ID = document.getElementById('country_search').value;
	if(ID!=""){
		document.getElementById('regions').innerHTML = '<img src="'+hostName+'/images/loader1.gif" align="absmiddle" alt="Loader" border="0" title="Please Wait" class="changeStatus" />';
		changeDropdownResponse1(hostName+'/ajax_call.php?mode=country1&id='+ID);
	}
}

function changeDropdownResponse1(page) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('regions').innerHTML = getValue;
		}
	}
	oHTTP.send(null);
} 


function changeDropDownCountry(){
	
	var ID = document.getElementById('country').value;
	if(ID!=""){
		document.getElementById('regionchange').innerHTML = '<img src="'+hostName+'/images/loader1.gif" align="absmiddle" alt="Loader" border="0" title="Please Wait" class="changeStatus" />';
		changeDropdownResponseCountry(hostName+'/ajax_call.php?mode=countryChange&id='+ID);
	}
}

function changeDropdownResponseCountry(page) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('regionchange').innerHTML = getValue;
		}
	}
	oHTTP.send(null);
} 


function search_check(){
	var check = 0;
	myOption = -1;
	for (i=document.talent_search.search_radio.length-1; i > -1; i--) {
		if (document.talent_search.search_radio[i].checked) {
		myOption = i; 
		i = -1;
		}
	}
	if (myOption == -1) {
	check++;
	alert("You must select search type");
	return false;
}
	if(document.talent_search.search_field.value == ""){
		check++;
		document.talent_search.search_field.focus();
		alert("Please enter some text");
		return false;
		
	} else{
		var field = document.talent_search.search_field.value;
	}
	if(check == 0){
		for (i=document.talent_search.search_radio.length-1; i > -1; i--) {
		if (document.talent_search.search_radio[i].checked) {
		if(document.talent_search.search_radio[i].value == "talent"){
			location.href='../talent_search.php?search_field='+field;
		}
		if(document.talent_search.search_radio[i].value == "audition"){
			location.href='../casting_search.php?search='+field;
		}
		}
	}
	}
	
	return true;
}

function search_check_new(){
	if(document.talent_search.search_field.value == ""){
		document.talent_search.search_field.focus();
		alert("Please enter some text");
		return false;
	} else {
    	var field = document.talent_search.search_field.value;
    	location.href='../talent_search.php?search_field='+field;
    }
    return true;
}

function left_panel_check(){
	var check = 0;
	if(document.left_browse.browse_picture.value == ""){
		check++;
	}
	if(document.left_browse.browse_video.value == ""){
		check++;
	}
	if(check > 1){
		alert("You can upload video or image or both");
		return false;
	}
	return true;
}

function markAllSelectedRows(container_id) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
	
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                /*if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' selected_bg';
                    marked_row[unique_id] = true;
                }*/
            }
        }
    }
    return true;
}


function unMarkSelectedRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            //rows[i].className = rows[i].className.replace(' selected_bg', '');
            //marked_row[unique_id] = false;
        }
    }

    return true;
}

function opentr(){
	document.getElementById('reply_email').style.display = '';
}

function payment_check(){
	var radio_check = false;
	for (counter = 0; counter < document.payment.month.length; counter++)
	{
		if (document.payment.month[counter].checked){
			radio_check= true; 
		}
	}
	if(radio_check == false){
		alert("Please select a payment package");
		//document.payment.month.focus();
		return false;
	}
	if(document.payment.payment_type.value == "")
	{
		alert("Please select payment type");
		document.payment.payment_type.focus();
		return false;
	}
	return true;
}

function package_check(){
	var radio_check = false;
	for (counter = 0; counter < document.choose_package.month.length; counter++)
	{
		if (document.choose_package.month[counter].checked){
			radio_check= true; 
		}
	}
	if(radio_check == false){
		alert("Please select a payment package");
		//document.payment.month.focus();
		return false;
	}
	if(document.choose_package.payment_type.value == "")
	{
		alert("Please select payment type");
		document.choose_package.payment_type.focus();
		return false;
	}
	
	return true;
}

function set_val(){
	document.getElementById("r_search").value = document.getElementById("region_search").value;
}

function apply_fob_check(){
	if(document.applyforfob.job_message.value == ""){
		alert("Please Enter Some Message");
		document.applyforfob.job_message.focus();
		return false;
	}
	if(document.applyforfob.confirmation.checked == false){
		alert("Please Check I understand that my profile will be sent to the advertiser");
		//document.applyforfob.confirmation.focus();
		return false;
	}
	return true;
}

function payment_check(){
	if(document.payment_confirm.payment_type.value == "")
	{
		alert("Please select payment type");
		document.payment_confirm.payment_type.focus();
		return false;
	}
	
	return true;
}


function check_month_12(){
	if(!document.month_12.month.checked){
		alert("Please check Redio button");
		document.month_12.month.focus();
		return false;
	}
	if(document.month_12.payment_type.value == ""){
		alert("Please select Payment Type");
		document.month_12.payment_type.focus();
		return false;
	}
	
	return true;
}

function check_month_6(){
	if(!document.month_6.month.checked){
		alert("Please check Redio button");
		document.month_6.month.focus();
		return false;
	}
	if(document.month_6.payment_type.value == ""){
		alert("Please select Payment Type");
		document.month_6.payment_type.focus();
		return false;
	}
	
	return true;
}

function check_month_1(){
	if(!document.month_1.month.checked){
		alert("Please check Redio button");
		document.month_1.month.focus();
		return false;
	}
	if(document.month_1.payment_type.value == ""){
		alert("Please select Payment Type");
		document.month_1.payment_type.focus();
		return false;
	}
	
	return true;
}

function check1(){
	var i=0;
	var radio_check = false;
	if (!document.month_12.month[0].checked){
		alert("Please check Radio button");
		document.month_12.month[0].focus();
		i++;
		return false;
	}
	if(document.month_12.payment_type12.value == ""){
		alert("Please select Payment Type");
		document.month_12.payment_type12.focus();
		i++;
		return false;
	}
	if(i == 0){
	document.forms['month_12'].submit();
	}
	return true;
}
function check2(){
	var j=0;
	var radio_check = false;
	if (!document.month_12.month[1].checked){
		alert("Please check Radio button");
		document.month_12.month[1].focus();
		j++;
		return false;
	}
	if(document.month_12.payment_type6.value == ""){
		alert("Please select Payment Type");
		document.month_12.payment_type6.focus();
		j++;
		return false;
	}
	if(j == 0){
	document.forms['month_12'].submit();
	}
	return true;
}

function check3(){
	var k=0;
	var radio_check = false;
	if (!document.month_12.month[2].checked){
		alert("Please check Radio button");
		document.month_12.month[2].focus();
		k++;
		return false;
	}
	if(document.month_12.payment_type1.value == ""){
		alert("Please select Payment Type");
		document.month_12.payment_type1.focus();
		k++;
		return false;
	}
	if(k == 0){
	document.forms['month_12'].submit();
	}
	return true;
}

/*function check1(){
	var i=0;
	if(document.month_12.payment_type12.value == ""){
		alert("Please select Payment Type");
		document.month_12.payment_type12.focus();
		i++;
		return false;
	}
	if(i == 0){
	document.forms['month_12'].submit();
	}
	return true;
}

function check2(){
	var i=0;
	if(document.month_6.payment_type6.value == ""){
		alert("Please select Payment Type");
		document.month_6.payment_type6.focus();
		i++;
		return false;
	}
	if(i == 0){
	document.forms['month_6'].submit();
	}
	return true;
}

function check3(){
	var i=0;
	if(document.month_1.payment_type1.value == ""){
		alert("Please select Payment Type");
		document.month_1.payment_type1.focus();
		i++;
		return false;
	}
	if(i == 0){
	document.forms['month_1'].submit();
	}
	return true;
}*/

/*function check_month_12(){

	var radio_check = false;
	for (counter = 0; counter < document.month_12.month.length; counter++)
	{
		if (document.month_12.month[counter].checked){
			radio_check= true; 
		}
	}
	
	if(!document.month_12.month.checked){
		alert("Please check Redio button");
		document.month_12.month.focus();
		return false;
	}
	if(document.month_12.payment_type.value == ""){
		alert("Please select Payment Type");
		document.month_12.payment_type.focus();
		return false;
	}
	
	return true;
}*/

function paymentbypaypal_check(val){
	document.forms['paymentbypaypal'].elements['month'].value = val;
	document.paymentbypaypal.submit();
}



function subscriptionSelect(subType) {
	document.getElementById(subType).checked = true;
}

function ccPay() {
	var radios = document.forms["subscriptionForm"].elements["month"];
	var j=0;
	for(var i=0; i<radios.length; i++) {
		if(radios[i].checked == true){
			j = j+1;
		}
	}
	if(j<1){
		alert("Please select payment package");
		return false;
	}
	/*var radios = document.forms["subscriptionForm"].elements["month"];
	if(!radios.checked){
		alert("Please select payment package");
		return false;
	}*/
	if(document.subscriptionForm.card_type.value == "") {
		alert("Please select a card type");
		document.subscriptionForm.card_type.focus();
		return false;
	}
	if(document.subscriptionForm.card_number.value == "") {
		alert("Please enter a card number");
		document.subscriptionForm.card_number.focus();
		return false;
	}
	if(document.subscriptionForm.expiry_month.value == "") {
		alert("Please select an expiry month");
		document.subscriptionForm.expiry_month.focus();
		return false;
	}
	if(document.subscriptionForm.expiry_year.value == "") {
		alert("Please select an expiry year");
		document.subscriptionForm.expiry_year.focus();
		return false;
	}	
	if(document.subscriptionForm.ccv.value == "") {
		alert("Please enter a CCV number");
		document.subscriptionForm.ccv.focus();
		return false;
	}			
	document.subscriptionForm.payment_type.value = "cc";
	hideButton();
	document.subscriptionForm.submit();
}
function paypalPay() {
	var radios = document.forms["subscriptionForm"].elements["month"];
	var j=0;
	for(var i=0; i<radios.length; i++) {
		if(radios[i].checked == true){
			j = j+1;
		}
	}
	if(j<1){
		alert("Please select payment package");
		return false;
	}
	/*if(!radios.checked){
		alert("Please select payment package");
		return false;
	}*/
	document.subscriptionForm.payment_type.value = "paypal";
	hideButton();
	document.subscriptionForm.submit();
}
function onChangeCardType(cardType) {
	if (cardType == 'PAYPAL') {
		return paypalPay();
	}
}
function checkPayment(){
	return paypalPay();
}
function changeCardType(cardIndex) {
	document.subscriptionForm.card_type.selectedIndex = cardIndex;
	onChangeCardType(document.subscriptionForm.card_type.value);
}
function hideButton() {
	var submitButton = document.getElementById ? document.getElementById('submitButton') : document.all('submitButton');
	if (submitButton) {
		submitButton.style.display = 'none';
	}
}

function changeStatusFront(changeMode, ID, statusPortion){
	if(changeMode!="" && ID!="" && statusPortion!=""){
		document.getElementById(statusPortion).innerHTML = '<img src="'+hostName+'/admin_images/loader.gif" align="absmiddle" alt="Loader" border="0" title="Please Wait" class="changeStatus" />';
		changeStatusResponseFront(hostName+'/ajax_call.php?mode='+changeMode+'&id='+ID+'', changeMode, ID, statusPortion);
	}
}

function changeStatusResponseFront(page, changeMode, ID, statusPortion) {
	oHTTP.open("GET", page, true);
	
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="none") {
				document.getElementById(statusPortion).innerHTML = '<img src="'+hostName+'/admin_images/icon_inactive.gif" align="absmiddle" alt="Inactive" border="0" onclick="javascript: changeStatus(\''+changeMode+'\', '+ID+', \''+statusPortion+'\');" title="Unapproved" style="cursor:pointer;" />';
			}
			else{
				document.getElementById(statusPortion).innerHTML = '<img src="'+hostName+'/admin_images/icon_active.gif" align="absmiddle" alt="Active" border="0" onclick="javascript: changeStatus(\''+changeMode+'\', '+ID+', \''+statusPortion+'\');" title="Approved" style="cursor:pointer;" />';
			}
		}
	}
	
	oHTTP.send(null);
}

function deleteConfirmRecord(path, toDelete){
	if(confirm('Are you sure to delete this '+toDelete+'?')){
		location.href=''+path+'';
	}
	else{
		return false;	
	}
}
