﻿var Country ="";
var City ="";
var Town ="";
var District ="";
var Category = "";
var FromScript = false;
var FromScriptUserChoice = false;
var DestinationElementValue = "";
var functionToCall = "";
var kucuktur = "<";
var buyuktur = ">";
var amp = "&";
var cmbDistrictSelectedIndex= -1
var cmbSubDistrictSelectedIndex= -1
var cmbSearchRestaurantSelectedIndex= -1
var cmbSearchKitchenSelectedIndex= -1


String.prototype.trim = function()
{
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};
var elementname = "";
var Seciniz = "";
function openWindow(pageLink) {
popupWin=window.open(pageLink,'remote','width=620,height=600,top=100,left=100,scrollbars=yes')
}
function openWindowWide(pageLink) {
popupWin=window.open(pageLink,'remote','width=720,height=500,top=100,left=100,scrollbars=yes')
}
function openWindowWithWidthAndHeight(pageLink,width,height,positionTop,positionLeft,parUseScrollBar) {
    popupWin=window.open(pageLink,'remote','width='+width+',height='+height+',top='+positionTop+',left='+positionLeft+',scrollbars='+parUseScrollBar)
}
function openRestaurantImageGalery(pageLink)
{
    popupWin=window.open(pageLink,'remote','width=800,height=700,top=100,left=100,scrollbars=yes')
}

function PagePrint()
{
var popupWin=window.open('Print.aspx','remote','width=800,height=450,top=100,left=100,scrollbars=yes')
}

//her sayfada olmak zorunda onload=init();
function init(actionType)
{
    if(actionType=='PrintInterviewDetail' || actionType=='PrintRecipeDetail' || actionType=='PrintNewsAndActivityDetail' || actionType=='PrintRestaurantDetail') //print
    {
        window.print();
        window.close();
    }
}

function GemiusReturnActionType(actionType)
{
   if(actionType=="AnaSayfa")
    {
    return "p9M6Ff72L1Qw.Y01zdkuKbQYzdtWbubaKHJLIv40WDj.P7";
    }
   else if (actionType=="ContactUs")
   {
    return "AqiVfarNibnMk1p_LX7QRsdv35hkXe_8BNiDErgFImL.07";
   }
   else if (actionType=="NewsAndActivityDetail")
   {
    return ".A6VHPPGiTo7ELn6d23ondVqP8HBqq79cvbTBlrNIgr.p7";
   }
   else if (actionType=="NewsAndActivityList")
   {
    return "nAg7_QSR1GXB5uMVF4o8J6cU33iUXu_sZBgNm0COTXz.t7";
   }
   else if (actionType=="RestaurantDetail")
   {
    return "nAg7WQSR1OZru_MF3940EKcUfUqUXsdlxAFR8TiZTSD.Y7";
   }
   else if (actionType=="InterviewDetail")
   {
    return ".A6bGvPG5J6R1NMDd8gkwdUKHZbB6gcJcy2Lw9rzUJf.D7";
   }
   else if (actionType=="InterviewList")
   {
    return "nAiVHwSRiXDBnCCr3_OjPKcUfeCUXsdZZH4xqUAylbv.k7";
   }
   else if (actionType=="CateringDetail")
   {
    return "nAibGQSR5GchizjS7wpnKae0HbeUngcZxAurazgVOBP.y7";
   }
   else if (actionType=="CateringList")
   {
    return "AqiVfarNibnMWYAlZYi7pMdvfcBkXcdJZFu7r4fgwNn.m7";
   }
   else if (actionType=="RecipeDetail")
   {
    return ".A41vvPGeXCR2pAnPwrL9NUKfUnB6sdlcw1R8duzzTX.s7";
   }
   else if (actionType=="RecipeList")
   {
    return "nAiVfwSRiPDLF4Alb8y7HKcU33iUXu_sxJuDsh.pelv.l7";
   }
   else if (actionType=="RestaurantLogin")
   {
    return "nAg7_QSR1GXLwQm9p0ofLfTGHbeRqAcZE9eLIwNfUDf.U7";
   }
   else if (actionType=="Identity")
   {
    return "nAg1XQSReblrcPBG32LbCqe0fcCUnsdJjjjbNT1AeDz.p7";
   }
   else if (actionType=="SearchResult")
   {
    return "nGibGwQR5J5rS3M3F0KcWacUfcCUXsdJLq.bt0W6_KX.V7";
   }
   else if (actionType=="RestaurantImageGalery")
   {
    return ".AibGvQk5J6bCzkUT9tvoNTI3y3BNu_wSYmD0d3N_hL.X7";
   }
   else
   {
    return "p9M6Ff72L1Qw.Y01zdkuKbQYzdtWbubaKHJLIv40WDj.P7"; //AnaSayfa
   }
   
}

function clearCombo(objSelect){
    for (var i = (objSelect.options.length-1); i >= 0; i--)
    {
        objSelect.options[i]=null;
    }
}
function AddItemByCombo(Text,Value,Id)
{
    var opt = document.createElement("option");
    document.getElementById(Id).options.add(opt);
    opt.text = Text;
    opt.value = Value;
}

function LoadSelectedDay(id)
{
document.getElementById('tdCredit_'+id).innerHTML=CalculateTotalDay(document.getElementById('startDate_'+id).value,document.getElementById('endDate_'+id).value, id);    
}

function CalculateTotalDay(startDate,endDate,id)
{
    return ArapSabunu.CalculateTotalDay(startDate,endDate,id).value;
}

function CheckSelectedDay(year,mounth,day,advPlaceId,type,district)
{
    var totalCredit;
    totalCredit = CalculateTotalDayByAdvPlace(year,mounth,day, advPlaceId, type);
    if(document.getElementById('tdCredit_'+district).innerHTML!="")
        document.getElementById('tdCredit_'+district).innerHTML = parseInt(document.getElementById('tdCredit_'+district).innerHTML)+parseInt(totalCredit);     
    else
        document.getElementById('tdCredit_'+district).innerHTML = totalCredit;
}

function CalculateTotalDayByAdvPlace(year,mounth,day,advPlaceId, type)
{
    return ArapSabunu.CalculateTotalDayByAdvPlace(year,mounth,day,advPlaceId,type).value;
}

function LoadPollResult(pollid,choiceId)
{
   var str = GetPollResult(pollid,choiceId);
   var Arr = new Array();
   Arr = str.split(",@#");
   var index =1 ;
   var totalAnswer = 0;
   var HasValue = false;
   for(var i=0;i<Arr.length-1;i=i+2)
   {
        if(Arr[i] != "undefined" && Arr[i] != null)
        {
            document.getElementById('pollPersonCount_'+(index)).innerHTML = Arr[i]+' kişi ';
            document.getElementById('pollPercent_'+(index)).innerHTML = '%'+Arr[i+1];
            document.getElementById('pollImg_'+(index)).style.width = Arr[i+1];
            totalAnswer = totalAnswer+parseInt(Arr[i]);
            index++;
        }
        else
        {
            break;
        }
   }
   document.getElementById('divTotalParticipant').innerHTML = totalAnswer;
   if(Arr[Arr.length-1]==1)
        document.getElementById('pollResultLabel').innerHTML = "Anketimize katıldığınız için teşekkürler.";
   if(Arr[Arr.length-1]==0)
         document.getElementById('pollResultLabel').innerHTML = "Bu ankate daha önceden cevap vermiştiniz.";
}


function GetPollResult(pollid,choiceId)
{
   return ArapSabunu.GetPollResult(pollid,choiceId).value;
}

function AddAdvDistrict(obj,advType)
{
    for(i=0;i<obj.length;i++)
    {
        if(obj.options[i].selected)
            ArapSabunu.AddAdvDistrict(obj.options[i].value,advType);
    }
    GetComboValues('cmbOrderCity','cmbOrderDistrict');
}

function RemoveAdvDistrict(obj,advType)
{
    for(i=0;i<obj.length;i++)
    {
        if(obj.options[i].selected)
            RemoveAjaxAdvDistrict(obj.options[i].value,advType);
    }
    GetComboValues('cmbOrderCity','cmbOrderDistrict');
}
function RemoveAjaxAdvDistrict(value,advType)
{
    ArapSabunu.RemoveAdvDistrict(value,advType);
}



function getSelectedCheckboxValue(objChkGroup) {
   var selectedValue=''; 
   if(objChkGroup)
   {
       if(!objChkGroup.length)
            return objChkGroup.value;
       for (i=0; i<objChkGroup.length; i++){
        if (objChkGroup[i].checked==true)
            if(selectedValue=='')
                selectedValue = objChkGroup[i].value;
            else
                selectedValue += ','+objChkGroup[i].value;
        }
    }
   return selectedValue;
} 

function queryStringGetValue(param) 
{
   var URL = location.href
   if(param!=null) {
   var regEx = new RegExp("(\\?|&)("+param+"=)(.*?)(&|$|#)","i")
   var exec = regEx.exec(URL)
   var Sonuc = RegExp.$3
} 
else 
{
   var regEx = new RegExp("(\\?)(.*?)($)","i")
   var exec = regEx.exec(URL)
   var Sonuc = RegExp.$2
}
   return(Sonuc)
}



function RewritePage(pageNo)
{
    var str = document.location.href;
    var strStartPrefix;
    var strEndPrefix;
    var strLastIndex;
	var strLen;
	var pageStr;
	var pageArray;
	var paramArray;
	lastIndex = str.lastIndexOf(",");
	strStartPrefix = str.substr(0,parseInt(lastIndex)+1);
	strLen = str.length;
	pageStr = str.substr(parseInt(lastIndex)+1,parseInt(strLen)-parseInt(lastIndex));
	pageArray = pageStr.split(".html");
	strEndPrefix = pageArray[1];
	
	paramArray = pageArray[0].split("-");
	return strStartPrefix+paramArray[0]+'-'+pageNo+'-'+paramArray[2]+'.html'+strEndPrefix;
}

function GetRewritePageNo()
{
    var str = document.location.href;
    var strStartPrefix;
    var strEndPrefix;
    var strLastIndex;
	var strLen;
	var pageStr;
	var pageArray;
	lastIndex = str.lastIndexOf(",");
	strStartPrefix = str.substr(0,parseInt(lastIndex)+1);
	strLen = str.length;
	pageStr = str.substr(parseInt(lastIndex)+1,parseInt(strLen)-parseInt(lastIndex));
	pageArray = pageStr.split(".html");
	return pageArray[0].split("-")[1];
}

//alert(Math.random()*5);



function GetComboValuesSearch(sourceElement,destinationElement)
{
    	
    var i = -1;
    
    
    
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    
         
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenSelected(document.getElementById(destinationElement))
        document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        elementname = destinationElement;
        
        CallMethot(destinationElement,cID);
    }    
    
    //GetComboValues(sourceElement,'cmbSearchKitchen');
    //GetComboValues(sourceElement,'cmbSearchRestaurant');
    
}

function GetComboValues(sourceElement,destinationElement)
{
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenSelected(document.getElementById(destinationElement))
        document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        elementname = destinationElement;

        CallMethot(destinationElement,cID);
    
        
    }    
}

function CallMethot(DestinationElement,ID)
{
   
    if(DestinationElement == "cmbOrderDistrict")
    {
        ArapSabunu.GetAdvDistrictByCity(ID,document.getElementById('hdnAdvertisementType').value,callback_ForCombo);
    }
    
    if(DestinationElement == "cmbOrderSelectedDistrict")
    {
        ArapSabunu.GetAdvSelectedDistrictByCity(ID,document.getElementById('hdnAdvertisementType').value,callback_ForCombo);
    }
    
    if(DestinationElement == "cmbDistrict")
    {
        Seciniz='İlçe Seçiniz';
        ArapSabunu.GetDistrictByCity(ID,callback_ForCombo);
    }
    
    if(DestinationElement == "cmbCreditDistrict")
    {
        Seciniz='İlçe Seçiniz';
        ArapSabunu.GetCreditDistrictByCity(ID,callback_ForCombo);
    }
    
    if(DestinationElement == "cmbSubDistrict")
    {
        Seciniz='Semt Seçiniz';
        ArapSabunu.GetSubDistrictByDistrict(ID,callback_ForCombo);
    }
    if(DestinationElement == "cmbSearchKitchen")
    {
       Seciniz='Mutfak Tipi Seçiniz';
       var cityId;
       var i ;
       i = 0;
       i = document.getElementById('cmbCity').selectedIndex;
       cityId = document.getElementById('cmbCity').options[i].value 
       var districtId;
       i = 0;
       i = document.getElementById('cmbDistrict').selectedIndex;
       districtId = document.getElementById('cmbDistrict').options[i].value 
       var subDistrictId;
       i = 0;
       i = document.getElementById('cmbSubDistrict').selectedIndex;
       subDistrictId = document.getElementById('cmbSubDistrict').options[i].value 
       
       ArapSabunu.GetKitchenForSearch(cityId,districtId,subDistrictId,callback_ForCombo);
    }
    
    if(DestinationElement == "cmbSearchRestaurant")
    {
        Seciniz='Restoran Seçiniz';
       var cityId;
       var i ;
       i = 0;
       i = document.getElementById('cmbCity').selectedIndex;
       cityId = document.getElementById('cmbCity').options[i].value 
       var districtId;
       i = 0;
       i = document.getElementById('cmbDistrict').selectedIndex;
       districtId = document.getElementById('cmbDistrict').options[i].value 
       var subDistrictId;
       i = 0;
       i = document.getElementById('cmbSubDistrict').selectedIndex;
       subDistrictId = document.getElementById('cmbSubDistrict').options[i].value 
       
       var kitchenId;
       i = 0;
       i = document.getElementById('cmbSearchKitchen').selectedIndex;
       kitchenId = document.getElementById('cmbSearchKitchen').options[i].value 
       
       ArapSabunu.GetRestaurantForSearch(cityId,districtId,subDistrictId,kitchenId,callback_ForCombo);
      
    }
}



function ShowHighlight(pointElement)
{
      if(pointElement)
      {
        var con = pointElement;
        con.style.display = "block";      
        $(con).highlightFade('red');
      }
}

function ShowHighlightWhite(pointElement)
{
      if(pointElement)
      {
        var con = pointElement;
        con.style.display = "block";      
        $(con).highlightFade('white');
      }
}

function ChangeImg(src,width,height,elementName)
{
    elementHolder = document.getElementById(elementName);
    if(elementHolder == null)
        return
    elementHolder.innerHTML = '<img class=\'resim_border\' src=\''+src+'\' width=\''+width+'\' height=\''+height+'\' />';
}

function ChangeVideo(video,image,width,height,elementName)
{
    elementHolder = document.getElementById(elementName); 
    if(elementHolder == null)
        return
    elementHolder.innerHTML = '<div class=\'resim_border\' width=\''+width+'\' height=\''+height+'\'><object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\' width=\''+width+ '\' height=\''+height+'\'> <param name=\'movie\' value=\'http://video.milliyet.com.tr/Service/Video/Test.swf?clickTag='+video+'&amp;Resim='+image+'\'/><param name=\'wmode\' value=\'transparent\'/><param name=\'quality\' value=\'high\'/><embed src=\'http://video.milliyet.com.tr/Service/Video/Test.swf?clickTag='+video+'&amp;Resim='+image+'\' type=\'application/x-shockwave-flash\' height=\''+height+'\'></embed></object></div>';
}

function FormatNum(thisis,dig) {	
	var tempstr,newstr,str;
	var commapos,aftercomma;
	str = thisis.value;
	str = StrToMoney(str);	
	var mantissa = new String();	
	var tmp = new String();
	tmp = str;			
	if (tmp.indexOf(",",0)>0) {
		str = tmp.substring(0,tmp.indexOf(",",0))
		mantissa = tmp.substring(tmp.indexOf(",",0),tmp.length)
	}

	var output
	commapos=str.indexOf(";");
	if (commapos>=0) {
		aftercomma=str.substr(commapos);
		str=str.substr(0,commapos);
	}
	else aftercomma="";
	if (mantissa.length>dig)
	{
	    mantissa=mantissa.substring(0,dig+1);
	}
	if (str.length > 3) {
		tempstr=str;
		newstr="";
		while (tempstr.length>3)
		{
			newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
			tempstr=tempstr.substr(0,tempstr.length-3);
		}		
		output = tempstr+newstr+aftercomma;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	else
	{
		str		= str.replace('.','');
		output	= str;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	return true;
}
function StrToMoney(currency) {	
	var num = new String();
	num = currency;
	while (num.indexOf('.',0)>0) {
		num = num.replace('.','');
	}
	return num;
}
function ChangeImgWidthOutWidth(img,Link,ElementName)
{
    holder = kucuktur+'img border=\'0\' src=\''+img+'\' '+buyuktur;
    if(Link != '')
    {
	    linkStart = '<xsl:text disable-output-escaping="yes">&lt;</xsl:text>a href="'+Link+'"<xsl:text disable-output-escaping="yes">&gt;</xsl:text>';
	    linkEnd = '<xsl:text disable-output-escaping="yes">&lt;</xsl:text>/a<xsl:text disable-output-escaping="yes">&gt;</xsl:text>';
	}
	else
	{
	    linkStart = '';
	    linkEnd = '';
	}
	document.getElementById(ElementName).innerHTML = linkStart+holder+linkEnd;
}


function ConfirmAndSubmit(formObject,message,action)
{
	if(confirm(message))
	{
		formObject.action = action;
		formObject.submit();
		return;
	}
}
function GetInnerHtmlOfDiv(sourceElement,destinationElement)
{
    
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenDiv(document.getElementById(destinationElement));
        
        //document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        
        elementname = destinationElement;
       
        CallMethot(destinationElement,cID);
        
    }    
}
function GetInnerHtmlOfDivWithID(sourceElement,destinationElement)
{
    
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenDiv(document.getElementById(destinationElement));
        
        //document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        
        elementname = destinationElement;
       
        CallMethotWithID(destinationElement,cID);
        
    }    
}
function isEnterKeyPressed()
{
    if(event.which || event.keyCode)
	{
		if ((event.which == 13) || (event.keyCode == 13))
		{
            return true;			
		}
	}
	return false;
}

function ScriptElementParser(strScript,elementNameStart,elementNameFinish,arr,index)
{
    var Elements = arr;
    if(arr == null)
      Elements = new Array();  
    var startIndex = strScript.indexOf(elementNameStart);
    if(startIndex != -1)
    {
        finishIndex = strScript.indexOf(elementNameFinish);
        var evalJs = strScript.substring(startIndex+elementNameStart.length,finishIndex);
        Elements[index] = evalJs;
        index++;
        strScript=strScript.replace(elementNameStart,"");
        strScript = strScript.replace(elementNameFinish,"");
        return ScriptElementParser(strScript,elementNameStart,elementNameFinish,Elements,index);
    }
    return Elements;
    
}
function ClearObjects(objectNamesArray)
{
    for(k = 0; k<objectNamesArray.length;k++)
    {
        if(document.getElementById(objectNamesArray[k]))
            document.getElementById(objectNamesArray[k]).value = '';
    }
}
function callback_ForDiv(response)
{
       element = elementname;
       clearGivenDiv(document.getElementById(element));
       
       if(response.value== "false")
            return;
       else
       {
           var str = response.value;
           emts = ScriptElementParser(str,'<script>','</script>',null,0);
           var strA = '';
            for(var js=0;js<emts.length;js++)
            {
            //Hash tabledaki datalara gerek duyulduğu için bunlar tekrardan eval edilmesi gerekiyor.
            if(emts[js].indexOf(".put(") != -1)
            strA += emts[js];
            }
          
            if(document.getElementById(element))
            {  
                eval(strA);
                document.getElementById(element).innerHTML = str;
            }
       }
       if(FromScriptUserChoice)
       {
            if(element == 'Properties')
            {
                Category = "";
                //FromScript = false;
                //FillUserChoise();
                
                FillLabels();
                FillChBx();
                
                //FillContact();
                FromScriptUserChoice = false;
            }
       }
}
function callback_ForCombo(response)
{
       element = elementname;
       
            clearGivenSelected(document.getElementById(element));
       
           var str = response.value;
           var Arr = new Array();
           Arr = str.split(",@#");
           var index =0 ;
           document.getElementById(element).options[index] = new Option(Seciniz,'');
           index++;
           var HasValue = false;
           for(var i=0;i<Arr.length;i+=2)
           {
                if(Arr[i] != "undefined" && Arr[i+1] != "undefined" && Arr[i] != null && Arr[i+1] != null)
                {
                    document.getElementById(element).options[index] = new Option(Arr[i+1],Arr[i]);
                    index++;
                    
                    if(Arr[i] == DestinationElementValue)
                        HasValue = true;
                }
                else
                {
                    break;
                }
           }
           if(element=='cmbDistrict' && cmbDistrictSelectedIndex != -1 )
           {
                document.getElementById(element).selectedIndex=cmbDistrictSelectedIndex;
           }
           if(element=='cmbSubDistrict' && cmbSubDistrictSelectedIndex != -1)
           {
                document.getElementById(element).selectedIndex=cmbSubDistrictSelectedIndex;
           }
           if(element=='cmbSearchKitchen' && cmbSearchKitchenSelectedIndex != -1)
           {
                document.getElementById(element).selectedIndex=cmbSearchKitchenSelectedIndex;
           }
           if(element=='cmbSearchRestaurant' && cmbSearchRestaurantSelectedIndex != -1)
           {
                document.getElementById(element).selectedIndex=cmbSearchRestaurantSelectedIndex;
           }
            if(DestinationElementValue != "" && HasValue == true)
            {
               document.getElementById(element).value = DestinationElementValue;
               DestinationElementValue = "";
            }
            if(element == 'cmbDistrict')
            {
                Seciniz='Semt Seçiniz';
                GetComboValues('cmbDistrict','cmbSubDistrict');
                
//                Seciniz='Semt Seçiniz';
//                clearGivenSelectedNew(document.getElementById('cmbSubDistrict'));
//                Seciniz='Mutfak Tipi Seçiniz';
//                GetComboValues('cmbCity','cmbSearchKitchen');
                
            }
            if(element == 'cmbSubDistrict')
            {
                Seciniz='Mutfak Tipi Seçiniz';
                GetComboValues('cmbCity','cmbSearchKitchen');
            }
            if(element == 'cmbSearchKitchen')
            {
                Seciniz='Restoran Seçiniz';
                GetComboValues('cmbCity','cmbSearchRestaurant');
            }
            
            
             if(element == 'cmbOrderDistrict')
            {
                GetComboValues('cmbOrderCity','cmbOrderSelectedDistrict');
            }
            
           //GetComboValues('cmbCity','cmbSearchKitchen');
      
}
function callback_ForComboWithID(response)
{
       element = elementname;
       
       clearGivenSelected(document.getElementById(element));
       
       if(response.value== "false")
       {
            document.getElementById(element).options[0] = new Option('Seçiniz','');
            return;
       }
       else
       {
       
           var str = response.value;
           var Arr = new Array();
           Arr = str.split(",@#");
           var index =0 ;
           document.getElementById(element).options[index] = new Option(Seciniz,'');
           index++;
           var HasValue = false;
           for(var i=0;i<Arr.length;i+=2)
           {
                if(Arr[i] != "undefined" && Arr[i+1] != "undefined" && Arr[i] != null && Arr[i+1] != null)
                {
                    document.getElementById(element).options[index] = new Option(Arr[i]+' - '+Arr[i+1],Arr[i]);
                    index++;
                    if(Arr[i] == DestinationElementValue)
                        HasValue = true;
                }
                else
                {
                    break;
                }
           }
           
           if(DestinationElementValue != "" && HasValue == true)
           {
               document.getElementById(element).value = DestinationElementValue;
               DestinationElementValue = "";
           }
          
           if(FromScript == true)
           {
           
                if(element == 'City')
                {
                
                    document.getElementById(element).value = City;
                    if(City != '')
                        GetComboValues('City','Town');
                        else if(functionToCall != '')
                        {
                            setTimeout(functionToCall, 0);
                            functionToCall = "";
                        }
                }
                else if(element == 'Town')
                {
                    if(Town != '' && Town != '-1')
                        document.getElementById(element).value = Town;
                    if(Town != '')
                    GetComboValues('Town','District');
                    else if(functionToCall != '')
                        {
                            setTimeout(functionToCall, 0);
                            functionToCall = "";
                        }
                }
                else if(element == 'District')
                {
                    if(District != '' && District != '-1')
                        document.getElementById(element).value = District;
                    Country = "";
                    City = "";
                    Town = "";
                    District = "";
                    FromScript = false;
                    if(functionToCall != '')
                    {
                        setTimeout(functionToCall, 0);
                        functionToCall = "";
                    }
                }
                
           }
           if(FromScriptUserChoice)
           {
                if(element == 'Categories')
                {
                    document.getElementById(element).value = Category;
                    if(Category != '')
                        GetInnerHtmlOfDiv('Categories','Properties');
                }
           }
           //document.getElementById(element).selectedIndex = _index;
       }
}

function isValidEmail(Component)
{
	var filter = new RegExp("^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$", "i")
				
	if (filter.test(Component.value))
		return true
	else
		return false
}
function clearGivenSelectedNew(sel)
{
    while(sel.options.length)
        sel.remove(0);
    sel.options[0] = new Option(Seciniz,'');
}
function clearGivenDiv(sel)
{
    if(sel)
        sel.innerHTML = "";
}

function IsNumericAllowEmpty(Component)   
{

    strString = Component.value;
    
    var strValidChars = "0123456789 ";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return true;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function IsNumericAllowNull(Component)   
{

    strString = Component.value;
    
    var strValidChars = "0123456789 ";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function IsAlphanumericAllowNotNumeric(text)   
{

    var myRegxp = /([a-zA-Z_-]+)$/; 
    if(myRegxp.test(text)) 
    { 
        return true;
    } 
    return false;
}


function IsNumericAllowNotNull(Component)   
{

    strString = Component.value;
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
        
            blnResult = false;
        }
    }
    return blnResult;
}
function IsNumericAllowNotNullAllowNegative(Component)   
{

    strString = Component.value;
    var strValidChars = "0123456789-,";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
        
            blnResult = false;
        }
    }
    return blnResult;
}
function ThisIsMoneyField(Component)
{
    temp = Component.value.trim();
    temp = temp.replace(".","");
    Component.value = Replace(temp);
}
function Replace(data)
{
     var newstring = "";
     var strValidChars = "0123456789,";
     var commoExist = false;
     for (i = 0; i < data.length; i++)
     {
        strChar = data.charAt(i);
        if (strValidChars.indexOf(strChar) != -1)
        {
            if(strChar != ',' || !commoExist)
            {
                if(i != 0 || strChar != ',')
                {
                    newstring += strChar;
                    if(strChar == ',')
                commoExist = true;
                 }   
            }
            
        }
     }

    return newstring;
}
function IsMoneyAllowNotNull(Component)   
{
    strString = Component.value;
    var strValidChars = "0123456789.,";
    var strFirstValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;
    if (strFirstValidChars.indexOf(strString.charAt(0)) == -1 || strFirstValidChars.indexOf(strString.charAt(strString.length-1)) == -1) blnResult = false;

    
    
    for (i = 1; i < strString.length-2 && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function IsMoneyAllowNotNull2(Component)
{
    var countSeparator = 0;
    strString = Component.value;
    var strValidChars = "0123456789.,";
    var strFirstValidChars = "0123456789";
    var strSeparatorChars = ".,";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;
    if (strFirstValidChars.indexOf(strString.charAt(0)) == -1 || strFirstValidChars.indexOf(strString.charAt(strString.length-1)) == -1) blnResult = false;

    
    
    for (i = 1; i < strString.length-1 && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
        else
        {
            if(strSeparatorChars.indexOf(strChar)>=0)
                countSeparator = countSeparator+1;
        }        
    }
    if(countSeparator>1)
        blnResult = false;
        
    return blnResult;
}

function trim(stringToTrim)
{
return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function IsEmpty(strString)
{
    if(strString.trim() == "")
        return true;
    else
        return false;
}
function isComponentHasValue(Component)
{
    var v = Component.value.trim();
    if(v == "")
    {
      ShowHighlight(Component);
      return false;
    }
    return true;
}
function ShowHideDiv(ElementID)
{
    if(document.getElementById(ElementID))
    {
        if(document.getElementById(ElementID).style.display == 'none')
            document.getElementById(ElementID).style.display = 'block';
        else
            document.getElementById(ElementID).style.display = 'none';
    }
}
function GetIndexOfOptionByValue(Component,Value)
{
    if(Component != null)
    {
        
        for(i = 0; i < Component.options.length;i++ )
        {
            if(Component.options[i].value == Value)
                return i;
        }
    
    }
    return 0;
}

/**

Contructor(s):
 Hashtable()
          Creates a new, empty hashtable

Method(s):
 void clear() 
          Clears this hashtable so that it contains no keys. 
 boolean containsKey(String key) 
          Tests if the specified object is a key in this hashtable. 
 boolean containsValue(Object value) 
          Returns true if this Hashtable maps one or more keys to this value. 
 Object get(String key) 
          Returns the value to which the specified key is mapped in this hashtable. 
 boolean isEmpty() 
          Tests if this hashtable maps no keys to values. 
 Array keys() 
          Returns an array of the keys in this hashtable. 
 void put(String key, Object value) 
          Maps the specified key to the specified value in this hashtable. A NullPointerException is thrown is the key or value is null.
 Object remove(String key) 
          Removes the key (and its corresponding value) from this hashtable. Returns the value of the key that was removed
 int size() 
          Returns the number of keys in this hashtable. 
 String toString() 
          Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space). 
 Array values() 
          Returns a array view of the values contained in this Hashtable. 
 Array entrySet()
          Returns a reference to the internal array that stores the data. The Set is backed by the Hashtable, so changes to the Hashtable are reflected in the Set, and vice-versa.
        
*/
function Hashtable(){
this.hashtable = new Array();
}

/* privileged functions */

Hashtable.prototype.clear = function(){
this.hashtable = new Array();
}              
Hashtable.prototype.containsKey = function(key){
var exists = false;
for (var i in this.hashtable) {
    if (i == key && this.hashtable[i] != null) {
        exists = true;
        break;
    }       
}
return exists;
}
Hashtable.prototype.containsValue = function(value){
var contains = false;
if (value != null) {
    for (var i in this.hashtable) {
        if (this.hashtable[i] == value) {
            contains = true;
            break;
        }
    }
}        
return contains;
}
Hashtable.prototype.get = function(key){ 

return this.hashtable[key];
}
Hashtable.prototype.isEmpty = function(){
return (parseInt(this.size()) == 0) ? true : false;
}
Hashtable.prototype.keys = function(){
var keys = new Array();
for (var i in this.hashtable) {
    if (this.hashtable[i] != null)
        keys.push(i);
}
return keys;
}
Hashtable.prototype.put = function(key, value){
if (key == null || value == null) {
    throw "NullPointerException {" + key + "},{" + value + "}";
}else{
    this.hashtable[key] = value;
}
}
Hashtable.prototype.remove = function(key){
var rtn = this.hashtable[key];
this.hashtable[key] = null;
return rtn;
}    
Hashtable.prototype.size = function(){
var size = 0;
for (var i in this.hashtable) {
    if (this.hashtable[i] != null)
        size ++;
}
return size;
}
Hashtable.prototype.toString = function(){
var result = "";
for (var i in this.hashtable)
{     
    if (this.hashtable[i] != null)
        result += "{" + i + "},{" + this.hashtable[i] + "}\n";  
}
return result;
}                                  
Hashtable.prototype.values = function(){
var values = new Array();
for (var i in this.hashtable) {
    if (this.hashtable[i] != null)
        values.push(this.hashtable[i]);
}
return values;
}                                  
Hashtable.prototype.entrySet = function(){
return this.hashtable;
}

//----------------------------------------------------------------------------------------------------------------------------------------------
function GetKeysWhereClause(ht,value)
{
    var _keys = ht.keys();
    var result = new Array();
    var cnt = 0;
    for(i=0;i<_keys.length;i++)
    {
        if(_keys[i] != "clear" && _keys[i] != "addRange")
        {
            var v = ht.get(_keys[i]);
            
            if( v == value)
            {
                result[cnt] = _keys[i];
                cnt++;
            }
        }
    }
    return result;
}
function FillCombo(sourceidfull,sourceid,optionvalues,optionparentoptions,optionpropertyids,propertyparentpropertyids,propertydefaultvalues,globallables,destinationSelectedValue)
{
    
    var val = document.getElementById(sourceidfull+sourceid).value;
    
    if(val == "")
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
        return;
    }
    var parsedArray = GetKeysWhereClause(optionparentoptions,val);
    
    var destinationID = GetKeysWhereClause(propertyparentpropertyids,sourceid);
    if(destinationID.length ==1)
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues);
    
        var destination = document.getElementById(sourceidfull+destinationID[0]);
        clearGivenSelected(destination);
        destination.options[0] = new Option(globallables.get('Seciniz'),'');
        for(i=0;i<parsedArray.length;i++)
        {
            destination.options[i+1] = new Option(optionvalues.get(parsedArray[i]),parsedArray[i]);

        }
        if(destinationSelectedValue != null)
             destination.value = destinationSelectedValue;
    }
    
}
function FillComboWithID(sourceidfull,sourceid,optionvalues,optionparentoptions,optionpropertyids,propertyparentpropertyids,propertydefaultvalues,globallables,destinationSelectedValue)
{
    
    var val = document.getElementById(sourceidfull+sourceid).value;
    
    if(val == "")
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
        return;
    }
    var parsedArray = GetKeysWhereClause(optionparentoptions,val);
    
    var destinationID = GetKeysWhereClause(propertyparentpropertyids,sourceid);
    if(destinationID.length ==1)
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues);
    
        var destination = document.getElementById(sourceidfull+destinationID[0]);
        clearGivenSelected(destination);
        destination.options[0] = new Option(globallables.get('Seciniz'),'');
        for(i=0;i<parsedArray.length;i++)
        {
            destination.options[i+1] = new Option(parsedArray[i]+' - '+optionvalues.get(parsedArray[i]),parsedArray[i]);

        }
        if(destinationSelectedValue != null)
             destination.value = destinationSelectedValue;
    }
    
}
function FillListBox(sourceidfull,sourceid,optionvalues,optionparentoptions,optionpropertyids,propertyparentpropertyids,propertydefaultvalues,globallables)
{
    var val = document.getElementById(sourceidfull+sourceid).value;
    if(val == "")
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
        return;
    }
    
    var parsedArray = GetKeysWhereClause(optionparentoptions,val);
    
    var destinationID = GetKeysWhereClause(propertyparentpropertyids,sourceid);
    if(destinationID.length ==1)
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues);
    
        var destination = document.getElementById(sourceidfull+destinationID[0]);
        clearGivenSelected(destination);
        destination.options[0] = new Option('','');
        for(i=0;i<parsedArray.length;i++)
        {
            destination.options[i+1] = new Option(optionvalues.get(parsedArray[i]),parsedArray[i]);

        }
    }
}
function clearGivenSelected(sel,text)
{
    while(sel.options.length)
        sel.remove(0);
    sel.options[0] = new Option(text,'');
}
function SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
{
        var ClearArray;
        ClearArray = GetKeysWhereClause(propertyparentpropertyids,sourceid);
        var PropertyIDHolder = "";
        while(ClearArray.length > 0)
        {
            destcombo = document.getElementById(sourceidfull+ClearArray[0]);
            
            if(destcombo != null)
            {
                clearGivenSelected(destcombo,propertydefaultvalues.get(ClearArray[0]));
                destcombo = null;
                PropertyIDHolder = ClearArray[0];
            }
            ClearArray = GetKeysWhereClause(propertyparentpropertyids,PropertyIDHolder);
        }
}
function StartsWith(sText,TextSearch)
{
    
    if(sText.trim() == "")
        return false;
    if(TextSearch.trim() == "")
        return false;
    var temp = "";
    for(i = 0;i<TextSearch.length;i++)
    {
        if(sText.indexOf(TextSearch.charAt(i)) != -1)
        {
            temp += sText.charAt(i);
        }        
    }
    if(temp == TextSearch)
    {
    return true;
    }
    return false;
}

function queryStringGetValue(param) 
{
   var URL = location.href
   if(param!=null) {
   var regEx = new RegExp("(\\?|&)("+param+"=)(.*?)(&|$|#)","i")
   var exec = regEx.exec(URL)
   var Sonuc = RegExp.$3
} 
else 
{
   var regEx = new RegExp("(\\?)(.*?)($)","i")
   var exec = regEx.exec(URL)
   var Sonuc = RegExp.$2
}
   return(Sonuc)
}

//----------------------------------------------------------------------------------------------------------------------------------------

