function test(f_strTemp){
	return true;
}


// Netscape Resize Fix
if (document.layers) {
	widthCheck = window.innerWidth
	heightCheck = window.innerHeight
	window.onResize = resizeFix;
}
function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href
}

function pop(page, w, h) {
   if (!w) w = 600
   if (!h) h = 400
   var popWin = window.open(page, 'popWindow', 'width='+w+',height='+h+',resizable=no,scrollbars=yes')
   popWin.focus()
   return void(0)
}

function openWin(page, w, h) {
   if (!w) w = 790
   if (!h) h = 460
   var newWin = window.open(page, '_blank', 'width='+w+',height='+h+',location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes')
   newWin.focus()
   return void(0)
}

function openpopupitem(f_lngItemID, f_intWidth, f_intHeight){

//   if (!f_lngSectionID) f_lngSectionID = 1
   if (!f_intWidth) f_intWidth = 600
   if (!f_intHeight) f_intHeight = 450

   var popWin = window.open('pop_page.aspx?Item=' + f_lngItemID, 'popWindow', 'width=' + f_intWidth + ', height=' + f_intHeight + ',resizable=no,scrollbars=yes')

   popWin.focus()

   return void(0)

}

function openwinitem(f_lngSectionID, f_lngItemID, f_intWidth, f_intHeight){

//   if (!f_lngSectionID) f_lngSectionID = 1
   if (!f_intWidth) f_intWidth = 790
   if (!f_intHeight) f_intHeight = 460

   var newWin = window.open('page.aspx?Section=' + f_lngSectionID + '&Item=' + f_lngItemID, 'newWindow', 'width=' + f_intWidth + ',height=' + f_intHeight + ',location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes')

   newWin.focus()

   return void(0)

}

function checkForm(f_objForm){

	var strElementName;
	var strElementValue;
	var strElementType;
	var strPreviousElementName;
	var strTemp;
	var objElement;
	var blnChecked;
	var objErrorElement;
	var objCheckElement;

	for(var i = 0; i < f_objForm.length; i++){
		strElementName = f_objForm.elements[i].name
		strElementValue = f_objForm.elements[i].value
		strElementType = f_objForm.elements[i].type
		objElement = f_objForm.elements[i];
		objErrorElement = null;
		objCheckElement = null;

		switch(objElement.type){
			case 'radio':
//				if(objElement.name.substr(objElement.name.length-1, 1) == 'M'){
				if(f_objForm.hdnMandatoryFields.value.indexOf(objElement.name) > -1){
					blnChecked = false;
					strPreviousElementName = objElement.name;
					
					while(objElement.name == strPreviousElementName){
						if(objElement.checked) {blnChecked = true;}

						strPreviousElementName = objElement.name;

						i++;
						objElement = f_objForm.elements[i];
					}

					if(!blnChecked){
						objErrorElement = eval('document.forms["' + f_objForm.name + '"].' + strPreviousElementName.substr(0, strPreviousElementName.length) + '_NoValue_Err');
						if(objErrorElement)
							alert(objErrorElement.value);
						else
							alert(eval('document.forms["' + f_objForm.name + '"].hdnDefault_NoValue_Err.value'));

						i = f_objForm.length;
						return false;
					}
				}
				//break;
			default:
//				if(objElement.name.substr(objElement.name.length-1, 1) == 'M' && objElement.type != 'hidden'){
				if(f_objForm.hdnMandatoryFields.value.indexOf(objElement.name) > -1 && objElement.type != 'hidden'){
					if(objElement.value.length == 0){
						objErrorElement = eval('document.forms["' + f_objForm.name + '"].' + objElement.name.substr(0, objElement.name.length) + '_NoValue_Err');

						if(objErrorElement)
							alert(objErrorElement.value);
						else
							alert(eval('document.forms["' + f_objForm.name + '"].hdnDefault_NoValue_Err.value'));

						i = f_objForm.length;
						return false;
					}
					else{
						objCheckElement = eval('document.forms["' + f_objForm.name + '"].' + objElement.name.substr(0, objElement.name.length) + '_Check');

						if(objCheckElement){
							if(objElement.value.indexOf('"') > 0){
								objErrorElement = eval('document.forms["' + f_objForm.name + '"].' + objElement.name.substr(0, objElement.name.length) + '_WrongValue_Err');
								alert(objErrorElement.value);

								i = f_objForm.length;
								return false;
							}
							else{
								if(!eval(objCheckElement.value + '("' + objElement.value + '")')){
									objErrorElement = eval('document.forms["' + f_objForm.name + '"].' + objElement.name.substr(0, objElement.name.length) + '_WrongValue_Err');
									alert(objErrorElement.value);

									i = f_objForm.length;
									return false;
								}
							}
						}
					}
				}
				else{
					if(objElement.type.indexOf('select') == -1){
						if(objElement.value.length > 0){
							objCheckElement = eval('document.forms["' + f_objForm.name + '"].' + objElement.name.substr(0, objElement.name.length) + '_Check');

							if(objCheckElement){
								if(!eval(objCheckElement.value + '("' + objElement.value + '")')){
									objErrorElement = eval('document.forms["' + f_objForm.name + '"].' + objElement.name.substr(0, objElement.name.length) + '_WrongValue_Err');
									alert(objErrorElement.value);

									i = f_objForm.length;
									return false;
								}
							}
						}
					}
				}
		}
	
	}

/*	if(!isEmail(f_strEmail) && f_strEmail.length > 0){
		alert(f_strEmailErrorMsg);
		return false;
	}
	
	if(f_strHetu != '<not_mandatory>'){
		if(!tarkista_hetu(f_strHetu, true, f_strHetuErrorMsg, f_strHetuErrorMsg2))
			return false;
	}
*/	
	f_objForm.hdnSendMail.value = 'true';
	
	return true;

}

function addMandatoryField(f_objFieldList, f_strFieldName, f_strFieldNameToRemove){

	var regExp;
	var strTemp;
	var arrFieldNames;
	
	regExp = new RegExp(',' + f_strFieldName, 'g')
	strTemp = f_objFieldList.value.replace(regExp, '');
	f_objFieldList.value = strTemp;

	regExp = new RegExp(',' + f_strFieldNameToRemove, 'g')
	strTemp = f_objFieldList.value.replace(regExp, '');

	if(f_strFieldName != f_strFieldNameToRemove){
		f_objFieldList.value = strTemp;
		f_objFieldList.value += ',' + f_strFieldName;
	}
	else{
		 if(strTemp == f_objFieldList.value)
			f_objFieldList.value += ',' + f_strFieldName;
		 else
		 	f_objFieldList.value = strTemp;
	}

}

function checkChannelForm(f_objForm)
{
	if (CheckEmailAddress( f_objForm ))
	{
		if (CheckMobilePhone( f_objForm))
		{
			return true;		
		}
		else
		{
			alert(f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelMobilePhone_WrongValue_Err'].value);
			return false;		
		}
	}
	else
	{
		alert(f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelEmail_WrongValue_Err'].value);
		return false;
	}		
}

function CheckEmailAddress( f_objForm )
{
	strRegE = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.[A-Za-z0-9]+)|(-[A-Za-z0-9]+))*\.[A-Za-z]+(\s)*$/;

	if (f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelEmail'].value == '')
		return true;
		
	var email = f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelEmail'].value;
	if (email.length < 7)
		return false;

	if (f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelEmail'].value.search( eval(strRegE) ) == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckMobilePhone( f_objForm )
{
	strRegE = /^(\+)?([\d\s\-]{4,20})$/;

	if (f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelMobilePhone'].value == '')
		return true;
	
	var mobilephone = f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelMobilePhone'].value;
	if (mobilephone.length < 4)
		return false;

	if (f_objForm.elements['FeedbackLayout_ChannelForm1_txtChannelMobilePhone'].value.search( eval(strRegE) ) == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

