/******************************************
Module name : Js Function file
Parent module : None
Date created : 24th March 2008
Date last modified : 24th March 2008
Author :  Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : The functions_js.js file contains various functions related to the web site front end.
******************************************/	
/******************************************
Function name : showCategorySearchBox
Return type : None
Date created : 28 February 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function is used to show hide the seacch box
User instruction : showSearchBox(varDocumentID, varShow)
******************************************/
function showCategorySearchBox(varDocumentID, varShow)
{
	if(varShow == 'show')
	{
		document.getElementById(varDocumentID).style.display = 'block';	
	}
	else
	{
		document.getElementById(varDocumentID).style.display = 'none';
	}
	
}
/*****************************
Function name : validateUserSuggestCategoryForm
Return type : boolean
Date created : 16 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate suggested category for a user.
User instruction : validateUserSuggestCategoryForm(formname)
************************************/
function validateUserSuggestCategoryForm(formname)
{
	if(validateForm(document.getElementById(formname).id, 'frmCategoryName', 'Category Name', 'R'))
	{
		return true;
	}
	else 
	{
		return false;	
	}
}

/*****************************
Function name : setStandardPlanUpgradeOption
Return type : 
Date created : 14 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to set the value for plan for plan upgradation process.
User instruction : setStandardPlanUpgradeOption(formname, varPlanAttributeId)
************************************/
function setStandardPlanUpgradeOption(formname, varPlanAttributeId)
{
	//formname.submit();
	//return true;
	var PlanID = document.getElementById('frmGoingToNextPlanID').value = varPlanAttributeId; 
	var PlanName = document.getElementById('frmGoingToNextPlanName').value = 'standard'; 
	//alert(PlanID+"===="+PlanName);
	formname.submit();
	return true;
	//location.href = 'user_plan_upgradation.php?userNextPlan=standard';
}

/*****************************
Function name : setPremiumPlanUpgradeOption
Return type : 
Date created : 14 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to set the value for plan for plan upgradation process.
User instruction : setPremiumPlanUpgradeOption(formname, varPlanAttributeId)
************************************/
function setPremiumPlanUpgradeOption(formname, varPlanAttributeId)
{
	var PlanID = document.getElementById('frmGoingToNextPlanID').value = varPlanAttributeId; 
	var PlanName = document.getElementById('frmGoingToNextPlanName').value = 'premium'; 
	//alert(PlanID+"===="+PlanName);
	formname.submit();
	return true;
	//location.href = 'user_plan_upgradation.php?userNextPlan=premium';
}

/*****************************
Function name : validateInquiryForm
Return type : boolean
Date created : 9 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate the inquiry form.
User instruction : validateInquiryForm(formname)
************************************/
function validateInquiryForm(formname)
{
	var i = 0;
	var j = 0;
	
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var regBlank = /[^\s]/;
	var regSpace = /^([a-zA-Z0-9_#@!-]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9_#@]+)$/;
	var regChar = /^([a-zA-Z]+)$/;
	var regNumeric = /^([0-9]+)$/; 
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var regNumeric = /^([0-9]+)$/; 
	var varElementID;
	
	//var bolTermChecked = document.getElementById(formname).frmTermsCondition.checked;
	
	if(document.getElementById(formname).frmSubject.value == '') 
	{
		errorString += '- Niste popunili polje Naslov.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmSubject';	 
		}
	}
	if(document.getElementById(formname).frmMessage.value == '') 
	{
		errorString += '- Niste popunili polje Upit.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmMessage';	 
		}
	}
	if(document.getElementById(formname).frmFirstName.value == '') 
	{
		errorString += '- Niste popunili polje Ime.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmFirstName';	 
		}
	}
	if(document.getElementById(formname).frmLastName.value == '') 
	{
		errorString += '- Niste popunili polje Prezime.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmLastName';	 
		}
	}
	if(document.getElementById(formname).frmAddress.value == '') 
	{
		errorString += '- Upišite adresu.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmAddress';	 
		}
	}
	if(document.getElementById(formname).frmZip.value == '') 
	{
		errorString += '- Niste upisali Poštanski broj.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmZip';	 
		}
	}
	if(document.getElementById(formname).frmCity.value == '') 
	{
		errorString += '- Niste popunili polje Grad.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmCity';	 
		}
	}
	if(document.getElementById(formname).frmEmail.value == "") 
	{
		errorString += '- Niste popunili polje Email.\n';	 
		bolfocus = true; 
		varElementID = 'frmEmail';	 
	}
	else if(!regEmail.test(document.getElementById(formname).frmEmail.value))
	{
		errorString += '- Email sadrži pogrešan format.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmEmail';	 
		} 
	} 
	
	if(document.getElementById(formname).frmPhoneNumber.value == "") 
	{
		errorString += '- Niste popunili polje Broj telefona.\n';	 
		bolfocus = true; 
		varElementID = 'frmPhoneNumber';	 
	}
	
	/*if(!bolTermChecked)
	{
		errorString += '- Molimo vas akceptirajte pravila korištenja.\n';
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmTermsCondition';	 
		}
	}*/
	
	if(errorString == '')
	{
		return true;  
	}
	else
	{
		alert(MasterString+'\n'+errorString);  
		if(bolfocus)
		{
			//varElementID= 'frmfkPlanID';
			//document.getElementById(varElementID).focus();
		}
		return false;
	}
	
	
		
}

/*****************************
Function name : openDetailForUser
Return type : integer
Date created : 8 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to display detail information for a user.
User instruction : openDetailForUser(varUserID)
************************************/
function openDetailForUser(varUserID)
{
	window.open ('user_detail.php?userID='+varUserID, 'UserDetail', 'status=1, toolbar=1, height=500, width=600, scrollbars = yes, left=200,top=60');
}

/*****************************
Function name : displaySearchCity
Return type : integer
Date created : 7 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to display city for search states.
User instruction : displaySearchCity(stateID)
************************************/
function displaySearchCity(stateID)
{
	if(stateID == 'OutOfCroatia')
	{
		document.getElementById('frmVisibleSearchCity').innerHTML = '<div style="width:200px; float:left;">&nbsp;</div>';
	}
	else if(stateID == 'All')
	{
		document.getElementById('frmVisibleSearchCity').innerHTML = '<div style="width:200px; float:left;">&nbsp;</div>';	
	}
	else if(stateID == '' )
	{
		document.getElementById('frmVisibleSearchCity').innerHTML = '<div style="width:200px; float:left;">&nbsp;</div>';	
	}
	else
	{
		var QryStr = "SearchStateID="+stateID;
		doAjax('/ajax_action.php', QryStr, 'addSearchCity', 'get', '1');
	}
}

 /*****************************
Function name : addSearchCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to display the city after selecting states for search.
User instruction : addSearchCity(item)
****?*******************************/
 function addSearchCity(item)
  {
     if(item)
	  {	
		document.getElementById('frmVisibleSearchCity').innerHTML = item;
		
	  }
   }
  
/*****************************
Function name : displayCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to display city for states.
User instruction : DispayCity(formname)
************************************/
function displayCity(stateID, CityName)
{
	
	if(stateID == 'OutOfCrotia')
	{
		document.getElementById('frmVisibleCountryText').style.display = 'block';
		document.getElementById('frmVisibleStateText').style.display = 'block';
		document.getElementById('frmVisibleCityText').style.display = 'block';
		//document.getElementById('frmVisibleCpText').style.display = 'block';
		
		document.getElementById('frmVisibleCityLabel').style.display = 'none';
		document.getElementById('frmVisibleCity').style.display = 'none';
		document.getElementById('frmVisibleCpLabel').style.display = 'none';
		document.getElementById('frmVisibleCp').style.display = 'none';
    	document.getElementById('frmVisibleColonyLabel').style.display = 'none';
		document.getElementById('frmVisibleColony').style.display = 'none';
		
		
	}
	else
	{
		document.getElementById('frmVisibleCountryText').style.display = 'none';
		document.getElementById('frmVisibleStateText').style.display = 'none';
		document.getElementById('frmVisibleCityText').style.display = 'none';
		
		document.getElementById('frmVisibleCityLabel').style.display = 'block';
		document.getElementById('frmVisibleCity').style.display = 'block';
		document.getElementById('frmVisibleCpLabel').style.display = 'block';
		document.getElementById('frmVisibleCp').style.display = 'block';
    	document.getElementById('frmVisibleColonyLabel').style.display = 'block';
		document.getElementById('frmVisibleColony').style.display = 'block';
		
		
		//document.getElementById('frmVisibleCpText').style.display = 'none';
		
		var QryStr = "StateID="+stateID;
		doAjax('/ajax_action.php',QryStr,'addCity','get','1');
	}
}
 /*****************************
Function name : addCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to validate the User.
User instruction : addCity(formname)
************************************/
 function addCity(item)
  {
     if(item)
	  {	
		 document.getElementById('frmVisibleCity').innerHTML = item;
    	 document.getElementById('frmVisibleColony').innerHTML = 'Choose city to populate this.';
		 document.getElementById('frmVisibleCp').innerHTML = 'Choose colony to populate this.';
	  }
   }
  
  
/*****************************
Function name : displayCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to validate the User.
User instruction : DispayCity(formname)
************************************/
function disPlayColony(cityName,colonyName)
 {

	 var QryStr = "CityName="+cityName+"&editCompanyColony="+colonyName;;
	 doAjax('/ajax_action.php',QryStr,'addColony','get','1');
 }
	 
	 

/*****************************
Function name : addCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to validate the User.
User instruction : addCity(formname)
************************************/
 function addColony(item)
  {
     if(item)
	  {	
		 document.getElementById('frmVisibleColony').innerHTML = item;	
    	 document.getElementById('frmVisibleCp').innerHTML = 'Choose colony to populate this.';
	  }
   
  }  
  
  
   
/*****************************
Function name : disPlayCp
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to validate the User.
User instruction : disPlayCp(formname)
************************************/

function disPlayCp(colonyName,colonyCp)
 {
	 var QryStr = "ColonyName="+colonyName+"&editColonyCp="+colonyCp;
	 doAjax('/ajax_action.php',QryStr,'addCp','get','1');
 }

/*****************************
Function name : addCp
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to validate the?User.
User instruction : addCp(formname)
************************************/
 function addCp(item)
  {
     if(item)
	  {	
		 document.getElementById('frmVisibleCp').innerHTML = item;	
	  }
   
  }  
/*****************************
Function name : showProfileFormDiv
Return type : none
Date created : 1 April 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to set the the div status when user updates profile.
User instruction : showProfileFormDiv(formname, divForHide, divForShow)
************************************/
function showProfileFormDiv(formname, divForHide, mainButtonForHide, divForShow)
{
	/*if(divForHide == 'UserJobDetailDiv')
	{
		document.getElementById('ApplyTextDiv').style.display = 'none';		
	}
	else
	{
		document.getElementById('ApplyTextDiv').style.display = 'block';	
	}*/
	document.getElementById(divForHide).style.display = 'none';
	document.getElementById(mainButtonForHide).style.display = 'none';
	document.getElementById(divForShow).style.display = 'block';
}
/*****************************
Function name : showInquiryFormDiv
Return type : none
Date created : 1 April 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to set the the div status when user inquiry form.
User instruction : showInquiryFormDiv(formname, divForHide, divForShow)
************************************/
function showInquiryFormDiv(formname, divForHide, divForShow)
{
	document.getElementById(divForHide).style.display = 'none';
	document.getElementById(divForShow).style.display = 'block';
}
/*****************************
Function name : showInquiryDetailDiv
Return type : none
Date created : 2 April 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to set the the div status when user updates profile.
User instruction : showInquiryDetailDiv(formname, divForHide, divForShow)
************************************/
function showInquiryDetailDiv(formname, divForHide, divForShow)
{
	document.getElementById(divForHide).style.display = 'none';
	document.getElementById(divForShow).style.display = 'block';
}
/*****************************
Function name : showProfileDetailDiv
Return type : none
Date created : 2 April 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to set the the div status when user updates profile.
User instruction : showProfileDetailDiv(formname, divForHide, divForShow)
************************************/
function showProfileDetailDiv(formname, divForHide, mainButtonForShow, divForShow)
{
	/*if(divForHide == 'UserJobFormDiv')
	{
		document.getElementById('ApplyTextDiv').style.display = 'block';		
	}
	else
	{
		document.getElementById('ApplyTextDiv').style.display = 'none';	
	}*/
	document.getElementById(divForHide).style.display = 'none';
	document.getElementById(mainButtonForShow).style.display = 'block';
	document.getElementById(divForShow).style.display = 'block';
}

/*****************************
Function name : validUserBannerForm
Return type : boolean
Date created : 8 March 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 25 March 2008
Comments : This function is used to validate banner form while adding/updating a banner for a user.
User instruction : validUserBannerForm(formname)
************************************/
function validUserCompanyInfo(formname)
{
	if(document.getElementById(formname).frmUserState.value == 'OutOfCrotia')
	{
		if(validateForm(formname, 'frmUserCompanyName', 'Company Name', 'R', 'frmOutOfCrotiaCountry', 'Country', 'R',  'frmOutOfCrotiaCity', 'City', 'R', 'frmStreet', 'Street', 'R', 'frmUserCompanyHomePageUrl', 'Company Home Page', 'isUrl', 'frmUserPhone', 'Company Phone', 'R', 'frmUserEmailAddress', 'Email Address(User Name)', 'RisEmail', 'frmContactPerson', 'Contact Person', 'R', 'frmContactEmailAddress', 'Contact Email Address', 'RisEmail', 'frmContactPhone', 'Contact Phone', 'R'))
		{	
			return true;
		} 
		else 
		{
			return false;
		}
	}
	else
	{
		if(validateForm(formname, 'frmUserCompanyName', 'Company Name', 'R', 'frmUserState', 'State', 'R', 'frmUserCity','City','R','frmCp','CP', 'RisNan', 'frmStreet', 'Street', 'R', 'frmUserCompanyHomePageUrl', 'Company Home Page', 'isUrl', 'frmUserPhone', 'Company Phone', 'R', 'frmUserEmailAddress', 'Email Address(User Name)', 'RisEmail', 'frmContactPerson', 'Contact Person', 'R', 'frmContactEmailAddress', 'Contact Email Address', 'RisEmail', 'frmContactPhone', 'Contact Phone', 'R'))
		{	
			return true;
		} 
		else 
		{
			return false;
		}
	}
}

/*****************************
Function name : validUserLogoForm
Return type : boolean
Date created : 3 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate main logo form while adding/updating a main logo for a user.
User instruction : validUserLogoForm(formname)
************************************/
function validUserLogoForm(formname)
{
	if(validateForm(document.getElementById(formname).id, 'frmUserMainLogo', 'Main Logo', 'R'))
	{
		return true;
	}
	else 
	{
		return false;	
	}
}
/*****************************
Function name : validUserExtraImageForm
Return type : boolean
Date created : 3 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate extra photo 1 & 2 form while adding/updating a extra photos for a user.
User instruction : validUserExtraImageForm(formname)
************************************/
function validUserExtraImageForm(formname)
{
	if(document.getElementById('frmUserExtraPhoto1').value == '' && document.getElementById('frmUserExtraPhoto2').value == '')
	{
		if(validateForm(document.getElementById(formname).id, 'frmUserExtraPhoto1', 'Extra Photo 1', 'R', 'frmUserExtraPhoto2', 'Extra Photo 2', 'R'))
		{
			return true;
		}
		else 
		{
			return false;	
		}
	}
}



/*****************************
Function name : validUserBannerForm
Return type : boolean
Date created : 8 March 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 25 March 2008
Comments : This function is used to validate banner form while adding/updating a banner for a user.
User instruction : validUserBannerForm(formname)
************************************/
function validUserBannerForm(formname)
{
	if(document.getElementById('Image').style.display=='none')
	{
		if(validateForm(document.getElementById(formname).id, 'frmBannerTitle', 'Banner Title', 'R', 'frmBannerUrl', 'Banner URL', 'isUrl', 'frmBannerHTMLCode', 'Banner HTML Code', 'R'))
		{
			
			return true;
		}
		else 
		{
			return false;	
		}
		
	}
	if(document.getElementById('HTML').style.display=='none')
	{
	
		if(document.getElementById('frmBannerImageName').value =='' && document.getElementById('frmHiddenUploadedImage').value =='')
		{			
		
			if(validateForm(document.getElementById(formname).id, 'frmBannerTitle', 'Banner Title', 'R', 'frmBannerUrl', 'Banner URL', 'isUrl','frmBannerImageName', 'Banner Image', 'R'))
			{
				return true;
			}
			else 
			{
				return false;	
			}
			
		}
		
		else
		{	
			
			if(validateForm(document.getElementById(formname).id, 'frmBannerTitle', 'Banner Title', 'R', 'frmBannerUrl', 'Banner URL', 'isUrl'))
			{
				return true;
			}
			else 
			{
				return false;	
			}
		}
		
	}
}
/******************************************
Function name : getEditCatKeywords
Return type : boolean
Date created : 1 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to show all keywords (after selecting categories) while adding and updating user using ajax.
User instruction : getEditCatKeywords(formname)
******************************************/
function getEditCatKeywords(formname)
{
	var varCategoryLimit = document.getElementById(formname).frmHiddenCatLimit.value;
	var varObject = document.getElementById(formname).frmCategoryID;
	var arrSelectedCategoryID = new Array();
	j = 0 ;
	for(var i = 0; i < varObject.length; i++)
	{
		if(varObject.options[i].selected == true && varObject.options[i].value != '')	
		{
			arrSelectedCategoryID[j] = varObject.options[i].value;
			j++;
		}
		
	}
	var varSelectedCategoryCount = arrSelectedCategoryID.length;
	
	//MAKE COMMA SEPERATED VALUES FROM AN ARRAY.
	var varCommaSeperatedCategoryID = arrSelectedCategoryID.join(','); 
	if(varSelectedCategoryCount > varCategoryLimit)
	{
		alert("You can choose only "+ varCategoryLimit +" categories");	
		return false;
	}
	else
	{
		doAjax('/ajax_action.php', 'type=showKeyword&categoryID='+varCommaSeperatedCategoryID, 'getShowKeywords', 'GET');
	}
}

/*****************************
Function name : validateUserProductForm
Return type : boolean
Date created : 4 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate the product/services form
User instruction : validateUserProductForm(formname)
************************************/
function validateUserProductForm(formname)
{
	//check if category is selected or not
    var varCategoryLimit = document.getElementById(formname).frmHiddenCatLimit.value;
	var varObject = document.getElementById(formname).frmCategoryID;
	var arrSelectedCategoryID = new Array();
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var varElementID;
	var j = 0 ;
	var i =0;

 	for(i = 0; i < varObject.length; i++)
	{
		if(varObject.options[i].selected == true && varObject.options[i].value != '')	
		{
			arrSelectedCategoryID[j] = varObject.options[i].value;
			j++;
		}
	}
	
	var varSelectedCategoryCount = arrSelectedCategoryID.length;
	
	if(varSelectedCategoryCount == 0)
	{
	  	errorString += '- Niste popunili polje Kategorija.\n';
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmCategoryID';	 
		}
	}
	else if(varSelectedCategoryCount > varCategoryLimit)
	{
		errorString += '- You can choose only '+ varCategoryLimit +' categories.\n';	
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmCategoryID';	 
		}
	}
	
	//check for keyword is selected or not
	var varKeywordLimit = document.getElementById(formname).frmHiddenKeyLimit.value;
	var varKeywordObject = document.getElementById(formname).frmKeywordID;
	var arrSelectedKeywordID = new Array();
	j = 0 ;
	for(i = 0; i < varKeywordObject.length; i++)
	{
		if(varKeywordObject.options[i].selected == true && varKeywordObject.options[i].value != '')	
		{
			arrSelectedKeywordID[j] = varKeywordObject.options[i].value;
			j++;
		}
		
	}
	
	var varSelectedKeywordCount = arrSelectedKeywordID.length;
	if(varSelectedKeywordCount > varKeywordLimit)
	{
		errorString += '- Možete izabrati do'+ varKeywordLimit +' Ključnih riječi.\n';	
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmKeywordID';	 
		}
	}
	if(errorString == '')
	{
		if(validateForm(formname, 'frmUserShortCompanyInformation', 'Short Company Information', 'R'))
		{	
			return true;
		} 
		else 
		{
			return false;
		}
		return true;  
	}
	else
	{
		alert(MasterString+'\n'+errorString);  
		if(bolfocus)
		{
			document.getElementById(varElementID).focus();
		}
		return false;
	}
}

/*****************************
Function name : showFormFields
Return type : none
Date created : 28th March 2008
Date last modified : 28th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to show the form fields if Banking is choosen as Payment Type
User instruction : showFormFields(varID)
************************************/
function showFormFields(varValue)
{
	if(varValue == 'Transfer Money')
	{
		document.getElementById('Banking').style.display = 'block';
		document.getElementById('Paypal').style.display = 'none';
	  
	}
	else
	{
		document.getElementById('Paypal').style.display = 'block';	
	 	document.getElementById('Banking').style.display = 'none';
	}
}


/*****************************
Function name : resetDate
Return type : none
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to reset the date of a form
User instruction : resetDate()
*************?**********************/
function resetDate()
{
	document.forms[0].frmDate.value = "From";
	document.forms[0].frmTodate.value = "To";
}

/******************************************
Function name : toggleOption
Return type : None
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will toggle the select all checkbox option.
User instruction : toggleOption(spanChk)
******************************************/
function toggleOption(spanChk)
{
	var xState=spanChk.checked;
	var theBox=spanChk;

	elm=theBox.form.elements;
	
	for(i=0;i<elm.length;i++)
	{
		if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
		{
			if(xState == false)
				elm[i].checked = false;
			else
				elm[i].checked = true;
		}
	}
}


/******************************************
Function name : getMasterString
Return type : boolean
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the main string
User instruction : getMasterString()
******************************************/
function getMasterString()
{
	return "Žao nam je, ne možemo procesuirati\n Molimo vas da popunite prazna polja i popravite pogrešno upisana.\n";
}

/******************************************
Function name : checkError
Return type : boolean
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the true or false acording to form validation
User instruction : checkError(error)
******************************************/
function checkError(error)
{
	var flag=false;
	var MasterString = getMasterString();
	
	if(error != "")
	{
		MasterString = MasterString + error;
		flag=true;
	}
	
	if(flag == true)
	{
		alert(MasterString);
		return false;
	}
	else
		return true;
}


/*****************************
Function name : showBannerOptionsForViewProfile
Return type : boolean
Date created : 25th March 2008
Date last modified : 25th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to show banner option (it is HTML code or an Image) while adding a banner.
User instruction : showBannerOptionsForViewProfile(option)
************************************/
function showBannerOptionsForViewProfile(option)
{
	if(option == 'Image')
	{
		document.getElementById('Image').style.display = 'inline';
		document.getElementById('HTML').style.display = 'none';
		document.getElementById('BannerField').innerHTML = '<span style="color:#FF0000;">* </span>Banner Image:';
		document.getElementById('frmBannerImageName').focus();
		document.getElementById('frmBannerHTMLCode').value = '';
	}
	else
	{
		document.getElementById('Image').style.display = 'none';	
		document.getElementById('HTML').style.display = 'block';
		document.getElementById('BannerField').innerHTML = '<span style="color:#FF0000;">* </span>Banner HTML Code:';
		document.getElementById('frmBannerHTMLCode').focus();	
	}
}



/*****************************
Function name : showBannerOptions
Return type : boolean
Date created : 25th March 2008
Date last modified : 25th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to show banner option (it is HTML code or an Image) while adding a banner.
User instruction : showBannerOptions(option)
************************************/
function showBannerOptions(option)
{
	if(option == 'Image')
	{
		document.getElementById('Image').style.display = 'inline';
		document.getElementById('HTML').style.display = 'none';
		document.getElementById('BannerField').innerHTML = 'Banner Image:';
		document.getElementById('frmBannerImageName').focus();
		document.getElementById('frmBannerHTMLCode').value = '';
	}
	else
	{
		document.getElementById('Image').style.display = 'none';	
		document.getElementById('HTML').style.display = 'block';
		document.getElementById('BannerField').innerHTML = 'Banner HTML Code?';
		document.getElementById('frmBannerHTMLCode').focus();	
	}
}

/******************************************
Function name : getCatKeywords
Return type : boolean
Date created : 25th March 2008
Date last modified : 25th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function is used to show all keywords using ajax.
User instruction : getCatKeywords(varObject)
******************************************/
function getCatKeywords(formname)
{
	
	
	var varCategoryLimit = document.getElementById(formname).frmHiddenCatLimit.value;
	var varObject = document.getElementById(formname).frmCategory;
	var arrSelectedCategoryID = new Array();
	j = 0 ;
	for(var i = 0; i < varObject.length; i++)
	{
		if(varObject.options[i].selected == true && varObject.options[i].value != '')	
		{
			arrSelectedCategoryID[j] = varObject.options[i].value;
			j++;
		}
		
	}
	
	var varSelectedCategoryCount = arrSelectedCategoryID.length;
	//make comma seperated values from an array.
	var varCommaSeperatedCategoryID = arrSelectedCategoryID.join(','); 
	
	if(varSelectedCategoryCount > varCategoryLimit)
	{
		alert("Možete izabrati do "+ varCategoryLimit +" kategorije");	
		return false;
	}
	else
	{
		doAjax('/ajax_action.php', 'type=showKeyword&categoryID='+varCommaSeperatedCategoryID, 'getShowKeywords', 'GET');
	}
}

/******************************************
Function name : getShowKeywords
Return type : boolean
Date created : 25th March 2008
Date last modified : 25th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi 
Comments : Function is used to display the desired div which holds all the keywords according to the categories.
User instruction : getShowKeywords(varItem)
******************************************/
function getShowKeywords(varItem)
{
	document.getElementById('showKeywordDiv').innerHTML = varItem; 
	document.getElementById('showKeywordDiv').style.display = 'block'; 
}



/******************************************
Function name : validateForm
Return type : boolean
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will validate the required form
User instruction : validateForm()
******************************************/
function validateForm() 
{ 
	var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
	j=0;
	//	/^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)$/;
	var regEmail = /^[0-9a-zA-Z]+(([\.\-_])[0-9a-zA-Z]+)*@[0-9a-zA-Z]+(([\.\-])[0-9a-z-A-Z]+)*\.[a-zA-Z]{2,4}$/;
	var regBlank = /[^\s]/;
	//var regSpace = /[\s]/;
	var regSpace = /^([a-zA-Z0-9_#@!]+)$/;
	//var regAlphaNum = /^([a-zA-Z0-9-/_ :;#!@\n\r.,$*&%?^~`=+(){}\[\]\"\'\\]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
	 var regDate = /^([0-9_]+-[0-9][0-9]+-[0-9][0-9]+)$/; 
   var regChar = /^([a-zA-Z]+)$/;
	
	//alert (validateForm.arguments[1].name);
	//alert("sss--->"+document.forms[""+args[0]].elements[""+args[0]].value);
	for (i=1; i<(args.length-2); i+=3) 
	{	
		
		mesg=args[i+1];
		test=args[i+2]; 
		val=document.forms[""+args[0]].elements[""+args[i]];
		
		    if (val) 
			{	
				nm=mesg; 
				noVal = val;
				val = val.value;
				
			if(test=='BLNK')
			{
			 if (isNaN(val)) errors+='- '+nm+' mora imati Broj.\n';
			 if (val<0) errors+='- '+nm+' mora imati Broj.\n';
			 }			
			 else if(test=='CHKURL' && val !="")
				{
					p=val.indexOf('http://');
					s=val.indexOf('.');
			        if (p<0 || p==(val.length-1))
					{
						errors+='- '+nm+' mora biti vazeca web adresa, primjer:http://www.abc.com\n';
		
					}
					else if(s<p || s==(val.length-1))
					{
						errors+='- '+nm+' mora biti važeca web adresa, primjer: http://www.abc.com\n';
					}

				}
			 else
				{
			if(regBlank.test(val))
			{
				if(test.indexOf('isEqual')!=-1)
				{
					result = trim(val);

				if(result.length==0){
										
				errors += '- '+nm+' je obavezno.\n'; 
				}else{
					
					equal_obj_val = test.substring(8,test.indexOf(":"));
					mesg_string =test.substring((test.indexOf(":")+1));

					if(val != document.forms[""+args[0]].elements[""+equal_obj_val].value)
					{ 
						errors+='- '+nm+' and '+mesg_string+' must be same.\n';
					}
				}
				}
				else if(test.indexOf('isAlphaNum')!=-1)
				{
				result = trim(val);
				if(result.length==0){
				errors += '- '+nm+' je obavezno.\n'; 
				}else{
					if(!regAlphaNum.test(val))
					{
						errors += '- '+nm+' is not valid.\n';
						//errors+='- '+nm+': Only Alpha Numeric and "_ , . - ! @ # () {} [] " coma,  single cots and Chars Allowed.\n';
					}
				}
				
				}
				else if(test.indexOf('isSpace')!=-1)
				{
				result = trim(val);
				
				if(result.length==0)
				{
					errors += '- '+nm+' je obavezan.\n'; 
				}
				else
				{
					if(!regSpace.test(val))
					{
						errors+='- '+nm+': Samo brojevi i slova su"_ - ! @ # " dozvoljeni.\n';
						//errors += '- '+nm+' nije popunjen.\n';
					}
				}
				}
				else if (test.indexOf('isDate')!=-1) 
				{ 
					p=val.indexOf('-');
			       // alert(test.indexOf('isDate'));
			       	var sliptdate	= val.split("-");
					
					/*******************Added by rupesh Date is not before current date and month*********************/
					var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate(),TH=today.getHours();
					TM+=1;			
					if(TM<=9) 
					{	
						TM='0'+TM;
					}
					if(TD<=9)
					{
						TD='0'+TD;
					}
					/*******************Added by rupesh*********************/
					
					var sY=sliptdate[0];
					var sM=sliptdate[1];
					var sD=sliptdate[2];
					
					/*******************Added by rupesh*********************/
					//alert(TM);
					if(sY<TY ) {
						
						errors+='- '+nm+' Mora biti veci od današnjeg datuma.\n';
					}
					else if(sM==TM && sD<TD && sY==TY) { 

						errors+='- '+nm+' Mora biti veci od današnjeg datuma.\n';
						
					}
					else if(sM<TM && sY==TY) { 

						errors+='- '+nm+' Mora biti veci od današnjeg datuma.\n';
						
					}
					
					/*************************Added by rupesh********************/
					else if (p != 4 || sY.length != 4 || sM.length != 2 || sD.length != 2 )
					{
						errors+='- '+nm+' mora sadržavati važeci format za datum GGGG-MM-DD.\n';
		
					}
					else if(!regDate.test(val))
					{
						errors+='- '+nm+'  mora sadržavati važeci format za datum GGGG-MM-DD.\n';
					}
					else if(sM>12 || sD>31 || sY<2006)
					{
						errors+='- '+nm+'  mora sadržavati važeci format za datum GGGG-MM-DD.\n';
					}
			     }
				else if (test.indexOf('isEmail')!=-1) 
				{ 
					p=val.indexOf('@');
					s=val.indexOf('.');
			        if (p<1 || p==(val.length-1))
					{
						errors+='- '+nm+' mora sadržavati E-mail Adresu.\n';
		
					}
					//else if(s<p || s==(val.length-1))
					else if(!regEmail.test(val))
					{
						errors+='- '+nm+' mora sadržavati važecu e-mail Adresu.\n';
					}
			     }
				else if (test.indexOf('isUrl')!=-1) 
				{ 
					p=val.indexOf('http://');
					s=val.indexOf('.');
			        if (p<0 || p==(val.length-1))
					{
						errors+='- '+nm+' mora imati važecu adresu, Primjer: http://www.abc.com\n';
		
					}
					else if(s<p || s==(val.length-1))
					{
						errors+='- '+nm+' mora imati važecu adresu, Primjer: http://www.abc.com\n';
					}
			     }
				 else if(test.indexOf('isMp3')!=-1)
				 {
					function reverse(val) 
					{	
						var length = val.length;
						var letters = new Array(length);
						var letters2 = new Array(length);
						var backword = "";
						for (i=0; i<=length-1; i++) 
						{
							letters[i] = val.substring(i, i+1);
						}
						f = 0
						for (j=i-1; j>=0; j--) 
						{
							letters2[f] = letters[j];
							f++;
						}
						for (h=0; h<=letters2.length-1; h++) 
						{
							backword +=letters2[h];
						}
					 	return backword;
					}
					var back = reverse(val);
					var ValExt	= back.split(".");
					var ValExt = reverse(ValExt[0]);
					
					if (ValExt == "mp3" || ValExt == "MP3") 
					{
						flag="yes";
					} 
					else 
					{
						flag="no";						
					} 
					if(flag=="no")
					{
						errors+='- '+nm+' mora biti(mp3).\n';						
					}
				 
				 }
				 else if (test.indexOf('isChar')!=-1) 
				 { 
					var first_char;
					
					if(val.match(regChar)==null)
					{
					 	errors+='- '+nm+' mora sadržavati slova.\n';
					}
			     }
				 else if(test.indexOf('isCheckbox')!=-1)//Check is check box is not checked generate error
				{	
					var valueCheckbox = noVal.checked;
					if(!valueCheckbox)
					{
						errors+='- '+' Akceptirajte uvjete korištenja.\n';
					}
				}
	   			 else if (test!='R' || test=='Numbers') 
				 {
				 result = trim(val);
					if(result.length==0){
						
						if(errors.indexOf('Phone') == -1)
					errors += '- '+nm+' nije popunjeno.\n'; 
					}
					
				    if (isNaN(val)) 
					{
					 if(errors.indexOf('Phone') == -1)
					 errors+='- '+nm+' mora sadržavati broj.\n';
					}
					else
					{
					if(test=='Numbers' && !isNaN(val))
					{
					var i1;
					var num1=0;
						for (i1 = 0; i1 < val.length; i1++)
						{   
							// Check that current character is number.
							var c = val.charAt(i1);
							if (((c < "0") || (c > "9"))) num1=1;
						}
						if(num1==1)
						{
							if(errors.indexOf('Phone') == -1)
							errors+='- '+nm+' mora sadržavati broj.\n';
						}
					}
				 }
					if (test.indexOf('inRange') != -1) 
					{ num = parseFloat(val);
						p=test.indexOf(':');
						min=test.substring(8,p); 
						max=test.substring(p+1);
						
						if (num<min || max<num) 
							if(min==max)
							{
							  if(min==1 && max==1 & num==0)
								{
							errors+='- '+nm+' ne može biti ve?i od '+min+'.\n';
							    }
								if(min!=1 && max!=1 && min==max)
								{
							errors+='- '+nm+' ne može biti veci od '+min+'.\n';
								}
							}				
							
						else
						{
						errors+='- '+nm+' mora sadržavati broj izmedju '+min+' i '+max+'.\n';
						}
					} 
					if (val.indexOf('-') != -1) 
					{ 
						errors='- '+nm+' mora sadržavati broj.\n';
					} 
					if (val.indexOf('+') != -1) 
					{ 
						errors='- '+nm+' mora sadržavati broj.\n';
					}
					
				}else if (test.charAt(0)=='R')
				{
				result = trim(val);
				if(result.length==0){
					
				errors += '- '+nm+' nije popunjeno.\n'; 
				}
				} 
			}
			else if (test.charAt(0) == 'R' || test=='Numbers'){
				if(errors.indexOf('Phone') == -1 && test=='Numbers')
				{
				errors += '- '+nm+' nije popunjeno.\n'; 
				}
				if (test.charAt(0) == 'R')
				{					
				errors += '- '+nm+' nije popunjeno.\n'; 	
				}
			}
		}
			}
		if(errors !="")
		{	if(j<=0)
			{
				focusitem = document.forms[""+args[0]].elements[""+args[i]];
				j++;
			}	
		}
	} 
	
  if (errors)
  {
	var MasterString = getMasterString();
	alert(MasterString+'\n'+errors);
	focusitem.focus();
	return false;
   }
   else
	return true;

  document.MM_returnValue = (errors == '');
}

/******************************************
Function name : stripHTML
Return type : string
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the main string after removing HTML tags
User instruction : stripHTML(str)
******************************************/
function stripHTML(str){
      var re= /<\S[^><]*>(&nbsp;)*/g ;
      return str.replace(re, "") ;
}
/******************************************
Function name : ltrim
Return type : string
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the main string after removing white spaces from the left
User instruction : ltrim(str)
******************************************/
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
/******************************************
Function name : rtrim
Return type : string
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the main string after removing white spaces from the right
User instruction : rtrim(str)
******************************************/
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
/******************************************
Function name : trim
Return type : string
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the main string after removing white spaces from the right and left of the main string
User instruction : trim(str)
******************************************/
function trim(str) {
	return ltrim(rtrim(str));
}

/******************************************
Function name : isWhitespace
Return type : integer
Date created : 24th March 2008
Date last modified : 24th March 2008 
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : Function will return the index of white space encounter in the string.
User instruction : isWhitespace(charToCheck)
******************************************/
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}


/*****************************
Function name : validateAdminForm
Return type : boolean
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This is used to check admin login authentications.
User instruction : validateAdminForm(charToCheck)
************************************/
function validateUserLogin(formname)
{
	if(validateForm(formname,'frmUserName','Korisnicko ime(Email)', 'RisEmail', 'frmPassword','Lozinka','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

/*****************************
Function name : validateAdminForgotPassword
Return type : none
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to validate forgot password form.
User instruction : validateAdminForgotPassword(formname)
************************************/
function validateForgotPassword(formname)
{
	if(validateForm(formname,'frmUserName','Username(E-mail) ','RisEmail', 'frmSecurityCode','Verifikacijski kod','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

/*****************************
Function name : validateUserChangePassword
Return type : boolean
Date created : 24th March 2008
Date last modified : 24th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This is used to validate admin password and confirm passwords.
User instruction : validateUserChangePassword(formname)
************************************/
function validateUserChangePassword(formname)
{
	if(validateForm(document.getElementById(formname).id,'frmUserOldPassword', 'Trenutačna lozinka', 'RisSpace', 

'frmUserNewPassword', 'Nova lozinka','RisSpace','frmUserConfirmPassword', 'Potvrdi novu lozinku', 

'RisEqualfrmUserNewPassword:New Password'))
	{			
		var flag=confirm('Jeste li sigurni da želite promijeniti lozinku?')
		if(flag)
		{
			return true;
		}
		else
		{
			return false;		
		}
	} 
	else 
	{
		return false;
	} 
}

/*****************************
Function name : validateRegistrationStepOne
Return type : Boolean
Date created : 25th March 2008
Date last modified : 25th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This is used to validate registration Step first form.
User instruction : validateRegistrationStepOne(formname)
************************************/
function validateRegistrationStepOne(formname)
{
	var i = 0;
	var j = 0;
	
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var regBlank = /[^\s]/;
	var regSpace = /^([a-zA-Z0-9_#@!-]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9_#@]+)$/;
	var regChar = /^([a-zA-Z]+)$/;
	var regNumeric = /^([0-9]+)$/; 
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var regNumeric = /^([0-9]+)$/; 
	var varElementID;
   
    bolTermChecked = document.getElementById(formname).frmTermsAndCondition.checked;
	
	if(document.getElementById(formname).frmUserEmailAddress.value == "") 
	{
	errorString += '- Niste popunili polje Korisničko ime (Email).\n';	 
		bolfocus = true; 
		varElementID = 'frmUserEmailAddress';	 
	}
	else if(!regEmail.test(document.getElementById(formname).frmUserEmailAddress.value))
	{
		errorString += '- Korisničko ime (Email) mora imati važecu E-mail Adresu.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserEmailAddress';	 
		} 
	} 
	if(document.getElementById(formname).frmUserPassword.value == '') 
	{
		errorString += '- Niste popunili polje Lozinka.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserPassword';	 
		}
	}
	else if(!regSpace.test(document.getElementById(formname).frmUserPassword.value))
	{
		errorString += '- Lozinka je netočna.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserPassword';	 
		}  
	}
	   
	if(document.getElementById(formname).frmConfirmPassword.value == '') 
	{
		errorString += '- Niste popunili polje Potvrdi lozinku.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmConfirmPassword';	 
		}
	}
	else if(!regSpace.test(document.getElementById(formname).frmConfirmPassword.value))
	{
		errorString += '- Potvrdjena lozinka nije tocna.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmConfirmPassword';	 
		}  
	}
	   
	if(document.getElementById(formname).frmUserPassword.value != document.getElementById(formname).frmConfirmPassword.value)
	{
		errorString += '- Lozinke nisu iste.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserPassword';	 
		}
	}
	   
	if(document.getElementById(formname).frmUserCompanyName.value == '') 
	{
		errorString += '- Niste popunili polje Ime Tvrtke.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserCompanyName';	 
		}
	}
	    
	/*if(document.getElementById(formname).frmUserAddress.value == '') 
	{
		errorString += '- Niste popunili Polje Adresa.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmUserAddress';	 
		}
	}*/
	
	
	if(document.getElementById(formname).frmUserState.value == '') 
	{
		errorString += '- Niste popunili polje Županija.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmUserState';	 
		}
	}
	else
	{
		if(document.getElementById(formname).frmUserState.value == 'OutOfCrotia')
		{
			if(document.getElementById(formname).frmOutOfCrotiaCountry != undefined)
			{
				if(document.getElementById(formname).frmOutOfCrotiaCountry.value == '') 
				{
					errorString += '- Niste popunili polje Država.\n';	 
					if(!bolfocus )
					{
						bolfocus = true; 
						varElementID= 'frmOutOfCrotiaCountry';	 
					}
				}
			}
			
			/*if(document.getElementById(formname).frmOutOfCrotiaState != undefined)
			{
				if(document.getElementById(formname).frmOutOfCrotiaState.value == '') 
				{
					errorString += '- Niste popunili polje Županija.\n';	 
					if(!bolfocus )
					{
						bolfocus = true; 
						varElementID= 'frmOutOfCrotiaState';	 
					}
				}
			}*/
			
			if(document.getElementById(formname).frmOutOfCrotiaCity != undefined)
			{
				if(document.getElementById(formname).frmOutOfCrotiaCity.value == '') 
				{
					errorString += '- Niste popunili polje Grad.\n';	 
					if(!bolfocus )
					{
						bolfocus = true; 
						varElementID= 'frmOutOfCrotiaCity';	 
					}
				}
			}
		}
		else
		{
			if(document.getElementById(formname).frmUserCity != undefined)
			{
				if(document.getElementById(formname).frmUserCity.value == '') 
				{
					errorString += '- Niste popunili polje Grad.\n';	 
					if(!bolfocus )
					{
						bolfocus = true; 
						varElementID= 'frmUserCity';	 
					}
				}
			}

    		if(document.getElementById(formname).frmColony != undefined)
			{
				if(document.getElementById(formname).frmColony.value == '') 
				{
					errorString += '- Colony is required.\n';	 
					if(!bolfocus )
					{
						bolfocus = true; 
						varElementID= 'frmColony';
					}
				}
			}
			   
			if(document.getElementById(formname).frmCp != undefined)
			{
				if(document.getElementById(formname).frmCp.value == '') 
				{
					errorString += '- Niste popunili polje Poštanski broj.\n';	 
					if(!bolfocus )
					{
						bolfocus = true; 
						varElementID= 'frmCp';	 
					}
				}
			}	
		}
	}
	
	   
	if(document.getElementById(formname).frmStreet != undefined)
	{
		if(document.getElementById(formname).frmStreet.value == '') 
		{
			errorString += '- Niste popunili polje Ulica.\n';	 
			if(!bolfocus )
			{
				bolfocus = true; 
				varElementID= 'frmStreet';	 
			}
		}
	}
	
	
	if(document.getElementById(formname).frmUserCompanyHomePageUrl.value != '')
	{
		var p;
		var s;
		p = document.getElementById(formname).frmUserCompanyHomePageUrl.value.indexOf('http://');
		s = document.getElementById(formname).frmUserCompanyHomePageUrl.value.indexOf('.');
		if (p<0 || p==(document.getElementById(formname).frmUserCompanyHomePageUrl.value.length-1))
		{
			errorString += '- Web stranica tvrtke mora imati to?an format, Primjer: http://www.abc.com\n';

		}
		else if(s<p || s==(document.getElementById(formname).frmUserCompanyHomePageUrl.value.length-1))
		{
			errorString += '- Web stranica tvrtke mora imati tocan format, Primjer: http://www.abc.com\n';
		}
		
		 if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmUserCompanyHomePageUrl';	 
		  }
	}
	
	if(document.getElementById(formname).frmUserPhone.value == '') 
	{
		errorString += '- Niste popunili polje Telefon Tvrtke.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmUserPhone';	 
		}
	}
	
	
	
	/*if(document.getElementById(formname).frmUserCompanyType.value == '') 
	{
		errorString += '- Niste izabrali Djelatnost.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmUserCompanyType';	 
		}
	}*/
	  
	/*if(document.getElementById(formname).frmNumberOfEmployees.value != '') 
	{
		if(!regNumeric.test(document.getElementById(formname).frmNumberOfEmployees.value))
		{
			errorString += '- Number of Employees must contain a numeric value.\n';	 
			if(!bolfocus )
			{
				bolfocus = true; 
				varElementID= 'frmNumberOfEmployees';	 
			}
		}
		else
		{
			if(document.getElementById(formname).frmNumberOfEmployees.value.length > 10)
			{
				errorString += '- Tekst u polje Radno vrijeme je predug.\n';	 
				if(!bolfocus )
				{
					bolfocus = true; 
					varElementID= 'frmNumberOfEmployees';	 
				}	
			}
		}
	}*/
	   
	if(document.getElementById(formname).frmContactPerson.value == '') 
	{
		errorString += '- Niste popunili polje Kontakt osoba.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmContactPerson';	 
		}
	}
	   
	if(document.getElementById(formname).frmContactEmailAddress.value == '') 
	{
		errorString += '- Niste popunili polje Kontakt Mail.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmContactEmailAddress';	 
		}
	}
	else if(!regEmail.test(document.getElementById(formname).frmContactEmailAddress.value))
	{
		errorString += '- Kontakt E-mail mora imati korektan format.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmContactEmailAddress';	 
		} 
	}
	  
	if(document.getElementById(formname).frmContactPhone.value == '') 
	{
		errorString += '- Niste popunili polje Telefon.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmContactPhone';	 
		}
	}
	
	
	
	if(!bolTermChecked)
	{
		errorString += '- Molimo Vas akceptirajte Uvjete korištenja.\n';
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmTermsAndCondition';	 
		}
	}
	   
	if(document.getElementById(formname).frmfkPlanID[0].checked == false && document.getElementById(formname).frmfkPlanID[1].checked == false && document.getElementById(formname).frmfkPlanID[2].checked == false)
	{
		errorString += '- Niste izabrali Paket.\n';
	}

	if(errorString == '')
	{
		return true;  
	}
	else
	{
		alert(MasterString+'\n'+errorString);  
		if(bolfocus)
		{
			//varElementID= 'frmfkPlanID';
			//document.getElementById(varElementID).focus();
		}
		return false;
	}
}
	
/*****************************
Function name : validateRegistrationStepTwo
Return type : boolean
Date created : 26th March 2008
Date last modified : 26th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to validate the  registration step two form.
User instruction : validateRegistrationStepTwo(formname)
************************************/	
function validateRegistrationStepTwo(formname)
{
    //check if category is selected or not
    var varCategoryLimit = document.getElementById(formname).frmHiddenCatLimit.value;
	var varObject = document.getElementById(formname).frmCategory;
	var arrSelectedCategoryID = new Array();
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var varElementID;
	var j = 0 ;
	var i =0;

  for(i = 0; i < varObject.length; i++)
	{
		if(varObject.options[i].selected == true && varObject.options[i].value != '')	
		{
			arrSelectedCategoryID[j] = varObject.options[i].value;
			j++;
		}
		
	}
	
	var varSelectedCategoryCount = arrSelectedCategoryID.length;
	if(varSelectedCategoryCount == 0)
	{
	  errorString += '- Niste izabrali Kategorije.\n';
	   if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmCategory';	 
		  }
	 
	}
	else if(varSelectedCategoryCount > varCategoryLimit)
	{
		errorString += '- Možete izabrati do '+ varCategoryLimit +' kategorije.\n';	
		 if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmCategory';	 
		  }
	}
	
	//check for keyword is selected or not
	var varKeywordLimit = document.getElementById(formname).frmHiddenKeyLimit.value;
	var varKeywordObject = document.getElementById(formname).frmKeywordID;
	var arrSelectedKeywordID = new Array();
	j = 0 ;
	for(i = 0; i < varKeywordObject.length; i++)
	{
		if(varKeywordObject.options[i].selected == true && varKeywordObject.options[i].value != '')	
		{
			arrSelectedKeywordID[j] = varKeywordObject.options[i].value;
			j++;
		}
		
	}
	
	var varSelectedKeywordCount = arrSelectedKeywordID.length;
	/*if(varSelectedKeywordCount == 0)
	{
	  errorString += '- Niste izabrali kljucnu rijec.\n';
	  if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmKeywordID';	 
		  }
	}*/
	if(varSelectedKeywordCount > varKeywordLimit)
	{
		errorString += '- Možete izabrati do '+ varKeywordLimit +' ključnih riječi\n';	
		if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmKeywordID';	 
		  }
	}

	//check for product title
	if(document.getElementById(formname).frmShortCompanyInformation.value == '')
	{
	   errorString += '- Niste popunili polje Kratka informacija.\n';
	   if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmShortCompanyInformation';	 
		  }
	}
	
	//check for product description
	/*if(document.getElementById(formname).frmLongCompanyInformation.value == '' )
	{
	  errorString += '- Niste popunili polje Opis tvrtke.\n';
	   if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmLongCompanyInformation';	 
		  }
	}*/
	
	/*if(document.getElementById(formname).frmCompanyHomePage.value != '')
	{
		var p;
		var s;
		p = document.getElementById(formname).frmCompanyHomePage.value.indexOf('http://');
		s = document.getElementById(formname).frmCompanyHomePage.value.indexOf('.');
		if (p<0 || p==(document.getElementById(formname).frmCompanyHomePage.value.length-1))
		{
			errorString += '- Niste upisali korektno web stranicu URL Primjer: http://www.abc.com\n';

		}
		else if(s<p || s==(document.getElementById(formname).frmCompanyHomePage.value.length-1))
		{
			errorString += '- Niste upisali korektno web stranicu URL Primjer: http://www.abc.com\n';
		}
		
		 if(!bolfocus )
		  {
			bolfocus = true; 
			varElementID= 'frmCompanyHomePage';	 
		  }
	}*/
	
	if(errorString == '')
	{
		return true;  
	}
	else
	{
			alert(MasterString+'\n'+errorString);  
			if(bolfocus)
			{
			 document.getElementById(varElementID).focus();
			}
			return false;
			
			   
	 }
}

/*****************************
Function name : getKeywordLimit
Return type : boolean
Date created : 26th March 2008
Date last modified : 26th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to give alert message for keyword limit the user can select.
User instruction : getKeywordLimit(formname)
************************************/
function getKeywordLimit(formname)
{
	var varKeywordLimit = document.getElementById(formname).frmHiddenKeyLimit.value;
	var varKeywordObject = document.getElementById(formname).frmKeywordID;
	var arrSelectedKeywordID = new Array();
	j = 0 ;
	for(var i = 0; i < varKeywordObject.length; i++)
	{
		if(varKeywordObject.options[i].selected == true && varKeywordObject.options[i].value != '?')	
		{
			arrSelectedKeywordID[j] = varKeywordObject.options[i].value;
			j++;
		}
		
	}
	
	var varSelectedKeywordCount = arrSelectedKeywordID.length;
	
	if(varSelectedKeywordCount > varKeywordLimit)
	{
		alert("Možete izabrati do "+ varKeywordLimit +" ključnih riječi.");	
		return false;
	}
}

/*****************************
Function name : validateRegistrationStepThree
Return type : boolean
Date created : 28th March 2008
Date last modified : 28th March 2008
Author : Ashok Singh Negi
Last modified by : Ashok Singh Negi
Comments : This function is used to validate registration step three.
User instruction : validateRegistrationStepThree(formname)
************************************/
function validateRegistrationStepThree(formname)
{

if(document.getElementById(formname).frmPaymentOption.value == 'Banking' || document.getElementById(formname).frmPaymentOption.value == 'Transfer Money')
  {

	  //if(validateForm(formname,'frmOrderBankName', 'Bank Name', 'R', 'frmOrderBankAddress', 'Bank Address','R', 'frmOrderBankAccountNumber', 'Bank Account Number', 'R', 'frmBannerURL', 'Banner URL', 'isUrl'))
		if(validateForm(formname,'frmBannerURL', 'Banner URL', 'isUrl'))
		{			
				
				return true;
		} 
		else 
		{
				return false;
		} 
  }
 else
 {
	 if(validateForm(formname, 'frmBannerURL', 'Banner URL', 'isUrl'))
		{			
				
				return true;
		} 
		else 
		{
				return false;
		} 
 }
}


/***************************** Map24 *********************************************************************************/ 

/*****************************
Function name : Map24
Return type : none
Date created : 6rd Aprail 2008
Date last modified : 6rd Aprail 2008
Author :Vineet  Kumar
Last modified by : Vineet  Kumar
Comments : This function is used to validate the User.
User instruction : validateJobPost(formname)
************************************/
    
	function geocode(addressString ){
        map.Webservices.sendRequest(        
          new Map24.Webservices.Request.MapSearchFree(map, {
            SearchText: addressString,
            MaxNoOfAlternatives: 50
          })
        );
        
        map.onMapSearchFree = function( event ){
          var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl( map );
          var firstResult = event.Alternatives[0];
          var lon = firstResult.Coordinate.Longitude;
          var lat = firstResult.Coordinate.Latitude;
          
          mrcContainer.push(
            new Map24.Webservices.MRC.SetMapView({
              Coordinates: new Map24.Coordinate(lon,lat),
              ClippingWidth: new Map24.Webservices.ClippingWidth(
                { MinimumWidth: 5000 }              
              )
            })
          );
          
		  //for adding location
		mrcContainer.push(
          new Map24.Webservices.MRC.DeclareMap24Location({
            MapObjectID: "myLocation",
            Coordinate: new Map24.Coordinate(lon,lat),
            LogoURL: "http://img.map24.com/map24/3DSignet/signet3d22x20.gif",
            SymbolID: 20100
          })
        );
		  
		  mrcContainer.push(
          new Map24.Webservices.MRC.ControlMapObject({
            Control: "ENABLE",
            MapObjectIDs: "myLocation"
          })
        );
        mrcContainer.push(
          new Map24.Webservices.MRC.SetMapView({
            Coordinates: new Map24.Coordinate(lon,lat),
            ClippingWidth: new Map24.Webservices.ClippingWidth(
              { MinimumWidth: 5000 }            
            )
          })
        );
		//end for adding location
		  
		  //code for getting oval start from here
		  mrcContainer.push(
          new Map24.Webservices.MRC.DeclareMap24Oval({
            MapObjectID: "myOval",
            Width: 2000,
            Height:2000,
            Center: new Map24.Coordinate(lon,lat),
            FillColor: new Map24.Color( 255, 0, 0, 100 ),
            BorderColor: new Map24.Color( 0, 0, 0, 255 )
          })
        );
        mrcContainer.push(genControlMapObject( "ENABLE","myOval" ) );
        
         //code for getting level start from here		
		
	
		 mrcContainer.push(
          new Map24.Webservices.MRC.DeclareMap24Label({
            Anchor: "CENTER",
            Coordinate: new Map24.Coordinate(lon,lat),
            Color: new Map24.Color( { R:0, G:0, B:0, A:255 } ),
            BgColor: new Map24.Color( { R:255, G:255, B:255, A:255 } ),
            BorderColor: new Map24.Color( { R:255, G:0, B:0, A:255 } ),
            MapObjectID: "myLabel",
            Text: "Soccer Stadium of AJAX Amsterdam!"
          })
        );
		
		 mrcContainer.push(
          new Map24.Webservices.MRC.SetMapView({
            Coordinates: new Map24.Coordinate(lon,lat),
            ClippingWidth: new Map24.Webservices.ClippingWidth(
              { MinimumWidth: 4500 }  
            )          
          })
        );  
	   
	   // end of code of getting soccer	  
		   map.Webservices.sendRequest( mrcContainer );
        }
      }
	 
      function genControlMapObject( Control, id ){
        var ControlObject = new Map24.Webservices.MRC.ControlMapObject({
          Control: Control,
          MapObjectIDs: id
        });
        return ControlObject;
      }
      //end of code of getting oval
	  
	  //function start from zoom in and zoom out
	   function zoomin(){
        var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl();
        var mrcCommand = new Map24.Webservices.MRC.ModifyMapView({ Control: "ZOOMIN" });
        mrcContainer.push( mrcCommand );
        map.Webservices.sendRequest( mrcContainer );
      }
 
      function zoomout(){
        var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl();
        var mrcCommand = new Map24.Webservices.MRC.ModifyMapView({ Control: "ZOOMOUT" });
        mrcContainer.push( mrcCommand );
        map.Webservices.sendRequest( mrcContainer );
      }

/***************************** Map24 *********************************************************************************/ 
/*****************************
Function name : goForMap
Return type : none
Date created : 6rd Aprail 2008
Date last modified : 6rd Aprail 2008
Author :Vineet  Kumar
Last modified by : Vineet  Kumar
Comments : This function is used to validate the User.
User instruction : goForMap(formname)
************************************/
function goForMap(argUserID, mapType)
{
	if(mapType == 'map24')
	{
		window.open('map24.php?userID='+argUserID,'LocationMap','left=200,top=40,width=800,height=700,scrollbars=yes');
	}
	else
	{
		window.open('gmap.php?userID='+argUserID,'LocationMap','left=200,top=40,width=800,height=700,scrollbars=yes');	
	}
}
/*****************************
Function name : askPlanUpgrade
Return type : none
Date created : 6rd Aprail 2008
Date last modified : 6rd Aprail 2008
Author :Vineet  Kumar
Last modified by : Vineet  Kumar
Comments : This function is used to validate the User.
User instruction : askPlanUpgrade()
************************************/
function askPlanUpgrade()
{
	if(confirm("Da biste aktivirali vašu internet stranicu, trebate nadograditi vaš paket. Da li želite nadograditi?"))
	{
		location.href = 'my_plan.php';	
	}
	else
	{
		return false;	
	}
}
/*****************************
Function name : MyTip
Return type : none
Date created : 10 May 2008
Date last modified : 
Author :Prashant Bhardwaj
Last modified by : V
Comments : This function is used to show a tool tip
User instruction : MyTip()
************************************/

function MyTip(arg)
{
    switch(arg)
    {
    case "browser":
        return Tip("Gecko-Browsers (Firefox, Mozilla, Netscape 6+)<br>Konqueror<br>IE 5+<br>Opera 7+<br>Safari<br>and all W3C-DOM-conformant browsers", TITLE, "Supported Browsers", ABOVE, true, SHADOW, true, LEFT, true, FADEIN, 400, FADEOUT, 400);
    case "docu":
        return Tip("Read how simple it is to use the script. However, if you like to, you have also advanced possibilities to configure tooltips, either globally by setting the config variables in the script to the desired values, or individually through commands.", WIDTH, 300, SHADOW, true, ABOVE, true, LEFT, true, FADEIN, 400, FADEOUT, 400);
    case "download":
        return Tip("Go to the parag?aph where you can<br>download wz_tooltip.js as ZIP file", SHADOW, true, LEFT, true, FADEIN, 400, FADEOUT, 400);
    case "extensions":
        return TagToTip('T2TExtensions', BALLOON, true, ABOVE, true, LEFT, true, OFFSETX, -14, FADEIN, 400, FADEOUT, 400);
    case "features":
        return Tip("Short summary of features and capabilities", SHADOW, true, ABOVE, true, LEFT, true, FADEIN, 400, FADEOUT, 400);
    case "home":
        return Tip("Go to the startpage of walterzorn.com", SHADOW, true, FADEIN, 400, FADEOUT, 400);
    }
}
/*****************************
Function name : FixCalcXY
Return type : none
Date created : 10 May 2008
Date last modified : 
Author :Prashant Bhardwaj
Last modified by : V
Comments : This function is used to show a tool tip
User instruction : FixCalcXY()
************************************/
function FixCalcXY(el)
{
    if(typeof(el.offsetParent) == "undefined")
        return [70, 4000];
	var a = new Array(0, -70);
	while(el)
	{
		a[0] += el.offsetLeft || 0;
		a[1] += el.offsetTop || 0;
		el = el.offsetParent || null;
	}
	return a;
}
/*****************************
Function name : textInfoTextCounter
Return type : none
Date created : 12 May 2008
Date last modified : 
Author :Prashant Bhardwaj
Last modified by : 
Comments : This function is used to count the text limit for the text field.
User instruction : textInfoTextCounter(formname, maxlimit, textType)
************************************/
function textInfoTextCounter(formname, maxlimit, textType) 
{
	if(textType == 'LongInfo')
	{
		var fieldValue = document.getElementById(formname).frmLongCompanyInformation.value;
		var fieldValueLength = document.getElementById(formname).frmLongCompanyInformation.value.length;
		var countValue = document.getElementById(formname).remLongInfoLen1.value;
		if (fieldValueLength > maxlimit) 
		{
			document.getElementById(formname).frmLongCompanyInformation.value = document.getElementById(formname).frmLongCompanyInformation.value.substring(0, maxlimit);
		}	
		else
		{
			document.getElementById(formname).remLongInfoLen1.value = maxlimit - fieldValueLength;
		}	
	}
	else if(textType == 'ShortInfo')
	{
		var fieldValue = document.getElementById(formname).frmShortCompanyInformation.value;
		var fieldValueLength = document.getElementById(formname).frmShortCompanyInformation.value.length;
		var countValue = document.getElementById(formname).remShortInfoLen1.value;
		if (fieldValueLength > maxlimit) 
		{
			document.getElementById(formname).frmShortCompanyInformation.value = document.getElementById(formname).frmShortCompanyInformation.value.substring(0, maxlimit);
		}	
		else
		{
			document.getElementById(formname).remShortInfoLen1.value = maxlimit - fieldValueLength;
		}	
	}	 
}

/*****************************
Function name : textPorfileInfoTextCounter
Return type : none
Date created : 12 May 2008
Date last modified : 
Author :Prashant Bhardwaj
Last modified by : 
Comments : This function is used to count the text limit for the text field for profile updation.
User instruction : textPorfileInfoTextCounter(formname, maxlimit, textType)
************************************/
function textPorfileInfoTextCounter(formname, maxlimit, textType) 
{
	if(textType == 'LongInfo')
	{
		var fieldValue = document.getElementById(formname).frmUserLongCompanyInformation.value;
		var fieldValueLength = document.getElementById(formname).frmUserLongCompanyInformation.value.length;
		var countValue = document.getElementById(formname).remLongInfoLen1.value;
		if (fieldValueLength > maxlimit) 
		{
			document.getElementById(formname).frmUserLongCompanyInformation.value = document.getElementById(formname).frmUserLongCompanyInformation.value.substring(0, maxlimit);
		}	
		else
		{
			document.getElementById(formname).remLongInfoLen1.value = maxlimit - fieldValueLength;
		}	
	}
	else if(textType == 'ShortInfo')
	{
		var fieldValue = document.getElementById(formname).frmUserShortCompanyInformation.value;
		var fieldValueLength = document.getElementById(formname).frmUserShortCompanyInformation.value.length;
		var countValue = document.getElementById(formname).remShortInfoLen1.value;
		if (fieldValueLength > maxlimit) 
		{
			document.getElementById(formname).frmUserShortCompanyInformation.value = document.getElementById(formname).frmUserShortCompanyInformation.value.substring(0, maxlimit);
		}	
		else
		{
			document.getElementById(formname).remShortInfoLen1.value = maxlimit - fieldValueLength;
		}	
	}	 
}
/*****************************
Function name : validateContactForm
Return type : boolean
Date created : 9 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate the inquiry form.
User instruction : validateContactForm(formname)
************************************/
function validateContactForm(formname)
{
	var i = 0;
	var j = 0;
	
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var regBlank = /[^\s]/;
	var regSpace = /^([a-zA-Z0-9_#@!-]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9_#@]+)$/;
	var regChar = /^([a-zA-Z]+)$/;
	var regNumeric = /^([0-9]+)$/; 
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var regNumeric = /^([0-9]+)$/; 
	var varElementID;
	
	if(document.getElementById(formname).frmName.value == '') 
	{
		errorString += '- Niste popunili polje Ime.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmName';	 
		}
	}
	if(document.getElementById(formname).frmEmail.value == '') 
	{
		errorString += '- Niste popunili polje E-Mail.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmEmail';	 
		}
	}
	else if(!regEmail.test(document.getElementById(formname).frmEmail.value))
	{
		errorString += '- Email mora imate važecu adresu.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmEmail';	 
		} 
	} 
	if(document.getElementById(formname).frmMessage.value == '') 
	{
		errorString += '- Niste popunili polje Poruka.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmMessage';	 
		}
	}
	if(document.getElementById(formname).frmVerificationCode.value == '') 
	{
		errorString += '- Niste upisali verifikacijski kod.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmMessage';	 
		}
	}
	
	if(errorString == '')
	{
		return true;  
	}
	else
	{
		alert(MasterString+'\n'+errorString);  
		if(bolfocus)
		{
			//varElementID= 'frmfkPlanID';
			//document.getElementById(varElementID).focus();
		}
		return false;
	}
		
}

/*****************************
Function name : displayJobCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to display city for states.
User instruction : displayJobCity(formname)
************************************/
function displayJobCity(stateID, CityName)
{
	
	if(stateID == 'OutOfCrotia')
	{
		document.getElementById('frmVisibleCountryText').style.display = 'block';
		document.getElementById('frmVisibleStateText').style.display = 'block';
		document.getElementById('frmVisibleCityText').style.display = 'block';
		
		document.getElementById('frmVisibleCityLabel').style.display = 'none';
		document.getElementById('frmVisibleCity').style.display = 'none';
	}
	else
	{
		document.getElementById('frmVisibleCountryText').style.display = 'none';
		document.getElementById('frmVisibleStateText').style.display = 'none';
		document.getElementById('frmVisibleCityText').style.display = 'none';
		
		document.getElementById('frmVisibleCityLabel').style.display = 'block';
		document.getElementById('frmVisibleCity').style.display = 'block';
		
		var QryStr = "JobStateID="+stateID;
		doAjax('/ajax_action.php',QryStr,'addJobCity','get','1');
	}
}
 /*****************************
Function name : addJobCity
Return type : integer
Date created : 17 March 2008
Date last modified : 17 March 2008
Author : Vineet Kumar
Last modified by : Vineet Kumar
Comments : This function is used to validate the User.
User instruction : addJobCity(formname)
************************************/
 function addJobCity(item)
  {
     if(item)
	  {	
		 document.getElementById('fr?VisibleCity').innerHTML = item;
		 
	  }
   }
/*****************************
Function name : validateUserJobForm
Return type : boolean
Date created : 16 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate suggested category for a user.
User instruction : validateUserJobForm(formname)
************************************/
function validateUserJobForm(formname)
{
	/*if(document.getElementById('frmUserState').value == '')	
	{
		if(validateForm(document.getElementById(formname).id, 'frmUserJobTitle', 'Naziv Posla', 'R', 'frmUserJobCategory', 'Kategorija', 'R', 'frmUserState', 'Županija', 'R', 'frmUserJobContactEmail', 'Kontakt Email', 'isEmail' ))
		{
			return true;
		}
		else 
		{
			return false;	
		}		
	}
	else
	{
		if(document.getElementById('frmUserState').value == 'OutOfCrotia')	
		{
			if(validateForm(document.getElementById(formname).id, 'frmUserJobTitle', 'Naziv Posla', 'R', 'frmUserJobCategory', 'Kategorija', 'R', 'frmUserJobOutOfCroatiaCountry', 'Zemlja', 'R', 'frmUserJobOutOfCroatiaCity', 'Grad', 'R', 'frmUserJobContactEmail', 'Kontakt Email', 'isEmail'))
			{
				return true;
			}
			else 
			{
				return false;	
			}		
		}
		else
		{
			if(validateForm(document.getElementById(formname).id, 'frmUserJobTitle', 'Naziv posla', 'R', 'frmUserJobCategory', 'Kategorija', 'R', 'frmUserCity', 'Grad', 'R', 'frmUserJobContactEmail', 'Kontakt Email', 'isEmail'))
			{
				return true;
			}
			else 
			{
				return false;	
			}		
		}
	}*/
	if(validateForm(document.getElementById(formname).id, 'frmUserJobTitle', 'Naziv posla', 'R', 'frmUserJobCategory', 'Kategorija', 'R', 'frmUserJobContactEmail', 'Kontakt Email', 'RisEmail'))
	{
		return true;
	}
	else 
	{
		return false;	
	}
}
/*****************************
Function name : validateApplyForm
Return type : boolean
Date created : 16 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate suggested category for a user.
User instruction : validateApplyForm(formname)
************************************/
function validateApplyForm(formname)
{
	
	/*if(document.getElementById('frmApplicantUploadResume').value == '' && document.getElementById('frmApplicantCutPasteResume').value == '')	
	{
		if(validateForm(formname, 'frmApplicantLastName', 'Prezime', 'R', 'frmApplicantEmailID', 'Email', 'RisEmail', 'frmApplicantContactNumber', 'Kontakt Telefon', 'R', 'frmApplicantQualification', 'Kvalifikacija', 'R', 'frmApplicantExperience', 'Radno Iskustvo', 'R', 'frmApplicantUploadResume', 'Ubaci Životopis/Cut & Paste ', 'R'))
		{
			return true;
		}
		else 
		{
			return false;	
		}
	}
	else
	{*/
		if(validateForm(formname, 'frmApplicantLastName', 'Prezime', 'R', 'frmApplicantEmailID', 'Email', 'RisEmail',  'frmApplicantQualification', 'Kvalifikacija', 'R', 'frmApplicantExperience', 'Radno Iskustvo', 'R'))
		{
			return true;
		}
		else 
		{
			return false;	
		}	
	//}
}


/*****************************
Function name :setValidAction
Return type : none
Date created : 5th January 2008
Date last modified : 1 March 2008
Author : Prashant Bhardwaj
Last modified by : Prashant Bhardwaj
Comments : This function is used to perform on various Action like delete, activate , deactivate.
User instruction : setValidAction(value, formname,listname)
************************************/

function  setValidAction(value, formname,listname)
{
	if(value == 'Delete' || value.indexOf ('Delete')>-1)
	{
		message = "Izaberi "+listname;		
	}
	else
	{
		message = "promijeniti status "+listname;
	}
	var flag = validator(message,formname);			
	if(flag)
	{			
		formname.submit();
	}
	else
	{
		formname.frmChangeAction.value='';	
		document.getElementById('Main').checked = false;
		if(listname == 'posao')
		{
			document.forms[1].Main.checked=false;	
			elm=document.forms[1].elements;
			
		}
		else
		{
			document.forms[0].Main.checked=false;	
			elm=document.forms[0].elements;	
		}
		
		for(i=0;i<elm.length;i++)
		{
			//alert(elm[i].type);
			if(elm[i].type == "checkbox" )			{			
				elm[i].checked = false;
			}
			
		}
		return false;
	}
}
/******************************************
Function name : validator
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function will return the true or error message after validating checkboxes
User instruction : validator(btnType)
******************************************/
var btnType;
function validator(btnType,formname)
{
	
	var obj = formname;
	var error="", flagCheck=0;
	
	var len = obj.elements.length; 
	var i=0;
	for(i=0;i<len;i++) 
	{
		if(obj.elements[i].type=='checkbox')
		{
			if(obj.elements[i].checked)
			{
				//if(btnType == 'Delete')
					return askConfirm(btnType);
				//else
					//return true;
			}
			else
				flagCheck = 1;
		}
	}
	
	if(flagCheck == 1)
		error += "\n - Molimo Vas izaberite jedan record.";
			
	return checkError(error);
}
/*****************************
Function name : deSelectCheckbox
Return type : none
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to deselect check box
User instruction : deSelectCheckbox(formname)
************************************/
function deSelectCheckbox(formname)
{
	document.getElementById('Main').checked = false;
}
/******************************************
Function name : askConfirm
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function will return the true or false after asking for confirmation
User instruction : askConfirm(type)
******************************************/
function askConfirm(type)
{	
	var sen = "Jeste li sigurni da želite "+type+"?";
	if(confirm(sen))
		return true;
	else
		return false;
}

/*****************************
Function name : validateSearchSelectedCatKey
Return type : boolean
Date created : 16 April 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate suggested category for a user.
User instruction : validateSearchSelectedCatKey(formname)
************************************/
function validateSearchSelectedCatKey(formname)
{
	if(validateForm(document.getElementById(formname).id, 'keywordID', 'Ključna Riječ', 'R'))
	{
		return true;
	}
	else 
	{
		return false;	
	}		
}

/*****************************
Function name : textProductInfoTextCounter
Return type : none
Date created : 22 Jan 2009
Date last modified : 
Author :Prashant Bhardwaj
Last modified by : 
Comments : This function is used to count the text limit for the text field.
User instruction : textProductInfoTextCounter(formname, maxlimit, textType)
************************************/
function textProductInfoTextCounter(formname, maxlimit, productFieldID) 
{
	
	var fieldValue = document.getElementById('frmUserProductDescription'+productFieldID).value;
	var fieldValueLength = document.getElementById('frmUserProductDescription'+productFieldID).value.length;
	var countValue = document.getElementById('remProductInfoLen'+productFieldID).value;
	if (fieldValueLength > maxlimit) 
	{
		document.getElementById('frmUserProductDescription'+productFieldID).value = document.getElementById('frmUserProductDescription'+productFieldID).value.substring(0, maxlimit);
	}	
	else
	{
		document.getElementById('remProductInfoLen'+productFieldID).value = maxlimit - fieldValueLength;
	}	
}

/*****************************
Function name : navigateToShowClients
Return type : none
Date created : 20 April 2009
Date last modified : 
Author :Prashant Bhardwaj
Last modified by : 
Comments : This function is used to navigate to show 10 members logo.
User instruction : navigateToShowClients(formname, maxlimit, textType)
************************************/
function navigateToShowClients(selectedStateID)
{
	if(selectedStateID != '')
	{
		location.href = 'a_to_z.php?selectedStateID='+selectedStateID;	
	}
	else
	{
		location.href = 'a_to_z.php';		
	}
}

