﻿// JScript File
/////////////////////// Poll popup /////////////////////////
function doit(rooturl,ctrl,pid,cid){
var obj = document.getElementsByName(ctrl);
var radioLength = obj.length;
var pt;
var iflag=false;
	if(radioLength == undefined)
		if(obj.checked)
		{
			pt= obj.value;
			iflag= true;
		}
		else
			iflag=false;
	for(var i = 0; i < radioLength; i++) {
		if(obj[i].checked) {
			pt= obj[i].value;
			iflag= true;
		}
	}
	if(iflag == false)
	{
	    alert('يجب تحديد خيار');
	    //return false;
	}
	else
	    popitup(rooturl+'poll/poll_result.aspx?pid='+pid+'&pt='+pt+'&cid='+cid ,'417','440',50,110,1,0,0);
}

// Open Popup window
function popitup(url,iwidth,iheight,itop,ileft,iscrollbars,itoolbar,iresize) {

    //popitup('index.aspx',440,300,0,10,1,1,1);
    var mystr;
    
    if (iwidth=='full')
    mywidth= screen.availWidth;
    else
    mywidth=iwidth;

    if (iheight=='full')
    myheight= screen.availHeight;
    else
    myheight=iheight;
        
    if (iscrollbars==1)
    mystr='scrollbars,';
    
    if (itoolbar==1)
    mystr=mystr + 'toolbar,';
    
    if (iresize==1)
    mystr=mystr + 'resizable,';
    
	newwindow=window.open(url,'popupwindow','width=' + mywidth + ',height=' + myheight + ',top='+ itop + ',left=' + ileft + ',' + mystr + 'return false;');
	if (window.focus) {newwindow.focus()}
	return false;
}

/////////////// Poll check radiobutton //////////
function IsCheck(rooturl,ctrl,pid,cid)
{
    var checked = false;
    var pt;

    if ( document.getElementById(ctrl)!=null &&
     document.getElementById(ctrl).childNodes!=null)
     {
        for (var i=0;i<document.getElementById(ctrl).getElementsByTagName("input").length && !checked; i++)
        {
           if ( document.getElementById(ctrl).getElementsByTagName("input")[i].checked )
           {
              checked=true;
              pt= document.getElementById(ctrl).getElementsByTagName("input")[i].value;
           }
      }
    }
    //return checked;
    if(checked == false)
    {
        alert('يجب تحديد خيار');
        //return false;
    }
    else
        popitup(rooturl+'poll/poll_result.aspx?pid='+pid+'&pt='+pt+'&cid='+cid ,'417','440',50,110,1,0,0);
  
}


//////////////////////////////
function PlaceBanner()
{
		if ( screen.width > 800 )
        {
                mybanner = document.getElementById( "Bash_SideBanner" )
                winaxis = (document.all) ? ( document.body.clientWidth / 2 ) : ( ( window.innerWidth / 2 ) - 10 ) ;
				narrowscreenoffset = -20 ;
				
				if(screen.width < 1040)
				{
					narrowscreenoffset = 8 ;
					var content = document.getElementById("contentRegion");
					content.style.right = narrowscreenoffset + "px"; 
				}
				
				mybanner.style.left = (document.all) ? ( winaxis + 387 - narrowscreenoffset ) + "px" : ( winaxis + 385 - narrowscreenoffset ) + "px";
                document.getElementById( "Bash_SideBanner" ).style.display = "block" ;
        }
        else
        {
                document.getElementById( "Bash_SideBanner" ).style.display = "none" ;
        }
}

