﻿var configs={
//popup window ayarları
 noteList:function(params){
    return jsonConcat({objectType: 'iframe',width:380,minWidth:410,minHeight:300,maxHeight:500,preserveContent:false},params);
 },
 noteEdit:function(params){
    return jsonConcat({objectType: 'iframe',width:400,minWidth:400,minHeight:180,maxHeight:500,preserveContent:false},params);
 },
 opinionList:function(params){
    return jsonConcat({objectType: 'iframe',width:380,minWidth:410,minHeight:300,maxHeight:500,preserveContent:false},params);
 },
 opinionEdit:function(params){
    return jsonConcat({objectType: 'iframe',width:400,minWidth:400,minHeight:180,maxHeight:500,preserveContent:false},params);
 },
 pollList:function(params){
    return jsonConcat({objectType: 'iframe',width:400,minWidth:400,minHeight:300,maxHeight:500,preserveContent:false},params);
 },
 pollEdit:function(params){
    return jsonConcat({objectType: 'iframe',width:410,minWidth:410,maxHeight:500,preserveContent:false},params);
 },
 temayulList:function(params){
    return jsonConcat({objectType: 'iframe',width:400,minWidth:400,minHeight:300,maxHeight:500,preserveContent:false},params);
 },
 temayulEdit:function(params){
    return jsonConcat({objectType: 'iframe',width:380,minWidth:410,maxHeight:500,preserveContent:false},params);
 },
 
 galleryOptions: function(params) {
 return jsonConcat({ align: 'center', transitions: ['expand', 'crossfade'], fadeInOut: true, dimmingOpacity: 0.8, outlineType: 'rounded-white', marginBottom: 105, numberPosition: 'caption', slideshowGroup: 'slide1' }, params);
 },
 
 electionResult:function(params){
 return jsonConcat({ objectType: 'iframe',width:800,height:400, preserveContent: false, align: 'center' }, params);
 },

 cv: function(params) {
 return jsonConcat({ minWidth: 440, minHeight: 380, preserveContent: true, align: 'center' }, params);
 },
 
 cvAdd: function(params) {
 return jsonConcat({ objectType: 'iframe',minWidth: 440, minHeight: 380, preserveContent: false, align: 'center' }, params);
 }
 
};



function jsonConcat(o1, o2) {
 for (var key in o2) {
  o1[key] = o2[key];
 }
 return o1;
}

function addProccessAction()
{
    if(isEmpty($('proccessAction')))
        addFormParam('proccessAction','');
}
addLoadEvent(addProccessAction);

function doSubmit(action,method){ 
      method = isEmpty(method) ? "GET" : method;
       try{
           if(!window.validateForm || window.validateForm(cmdName)){              
              //if(!isEmpty(method))
                $('proccessAction').value=action;
                
              if (document.forms[0].onsubmit){
                 document.forms[0].onsubmit();
              }
              document.forms[0].method=method;
              //document.forms[0].action=addURLParam(document.forms[0].action,'sendMethod',method);  
              document.forms[0].submit();              
              return true;
              }
              return false;
         }
         catch(e){
        }    
 };

 //ilk parametre event olmalı,
 //openWindow(event, 'InformMessage', { minWidth: 270, width: 270, height: 110, minHeight: 110, preserveContent: true, align: 'center', headingText: 'Uyarı', maincontentText: 'TC Kimlik numarasını yanlış girdiniz!' });
 function openWindow(e,id,params,setPos)
 {
    try
    {   setPos=setPos==0?0:1;
        var lnk;
        if (!isEmpty(id))
            lnk=$('lnk'+id);
        else
            id=Math.random();
       
        if(isEmpty(lnk))
        {   
            lnk = document.createElement('a');
            lnk.id='lnk'+id;
            lnk.appendChild(document.createTextNode(''));
            lnk.href = '#';
            lnk.style.zIndex=-100;
            try{
            
            lnk.style.position='absolute';
           
                if(setPos)
                {
                    e = isEmpty(e)?window.event:e;
                    lnk.style.top=e.clientY+'px';                         
                    lnk.style.left=e.clientX+'px';
                }
                else
                {
                    lnk.style.top=(window.center().y-(window.size().height/8))+'px';                         
                    lnk.style.left=window.center().x+'px';
                }

            }catch(e){}
            document.body.appendChild(lnk);
        }
        if(!isEmpty(lnk))
        {
            lnk.onclick=function(){
                         hs.Expander.prototype.onDrop = winOnDrop;
                         hs.htmlExpand(this, params);
                         return false;
                        };
        }
        
        lnk.onclick(); 
    }
    catch(e){}
    
    return false;
}

function closeWindow(id){
    try
    {
        hs.close('lnk'+id); 
    }
    catch(e){}
    
    return false;
}
function refreshIframes()
{
    for(var i=0;i<hs.expanders.length;i++)
    {
        try{ 
            if(!isEmpty(hs.expanders[i].iframe) && window.frames[hs.expanders[i].iframe.name].location.href.toLowerCase().indexOf('proccessaction=list')!=-1){
                
                window.frames[hs.expanders[i].iframe.name].location.reload(true);
               }
        }catch(e){};
       
    }
}
function refreshWindows(time)
{
    setTimeout("refreshIframes();",time);
}

function reflowIframe()
{
    var exp=window.parent.hs.getExpander();
    if(exp)
        exp.reflow();
}

function deleteNote(id)
{ 
    if(window.confirm('Notu silmek istediğinizden emin misiniz?'))
    {
        $('delNote').value=id;
        doSubmit('listDelete');    
    }
    
}

function deletePoll(id)
{ 
    if(window.confirm('Bu anketi silmek istediğinizden emin misiniz?'))
    {
        $('delPoll').value=id;
        doSubmit('listDelete');    
    }
    
}
function deleteTemayul(id)
{ 
    if(window.confirm('Bu temayül dosyasını silmek istediğinizden emin misiniz?'))
    {
        $('delTemayul').value=id;
        doSubmit('listDelete');    
    }
    
}
function refresh(time)
{
    setTimeout("location.reload(true);",time);
}

function addFormParam(prm,val)
{
    var inputPrm= document.createElement('input');
    inputPrm.type="hidden";
    inputPrm.id=prm;
    inputPrm.name=prm;
    inputPrm.value=val;
    
    if(!isEmpty(document.forms[0]))
     document.forms[0].appendChild(inputPrm);
}
function addURLParam(url,prm,val)
{
    if(url.indexOf('?')==-1)
        url+='?'+prm+'='+val;
    else
    {
        if(url.indexOf(prm)!=-1)     
            url=url.replace(new RegExp( "([\?&]"+prm+")=([^&]*)", "g" ),"$1="+val);
         else
            url+='&'+prm+'='+val;
    }
    return url;
}

function activateSubmitBtn(val,id)
{
   $(id).disabled=(val.length!=11);
}


function refreshCVPart(part, cndID)
{
    loadC('dv'+part,'system/candidate/edit/'+part,'&cndID='+cndID);
    return false;
}


function deleteCVProperty(part, cndID, id)
{
    if(window.confirm('Bu kaydı silmek istediğinizden emin misiniz?'))
    {
        loadC('dv'+part,'system/candidate/edit/'+part,'&proccessAction=delete&cndID='+cndID+'&id='+id);    
    }
    return false;
}