﻿// JScript File
function underConstruction()
{
    alert("Under Construction");
}

function openCommonPopUp(Qid,Qtxt)
{
    window.open("../popup/popup_main.html?&QID="+Qid+"&Qtxt="&Qtxt,"Window1","menubar=no,width=768,height=595,toolbar=no,scrollbars=yes");
}



function submitCommon()
{
    var choice="";
    var tex=document.getElementById("txtCmn").value;
    var tex=getQuerystring('tex', 'no option');
    var Qtxt=getQuerystring('Qtxt', 'noQtxt');
    var qid=getQuerystring('QID', 'no option');
    if(tex=="")
    {
        alert("Please provide text");
    }
    else
    {
        window.location.href="../getSet.aspx?cmn=1&opt="+choice+"&tex="+tex+"&QID="+qid+"&Qtxt="+Qtxt;
    }
}

function submitIdCmn()
{
    var name=document.getElementById("txtName").value;
    var email=document.getElementById("txtCommon").value;
    var choice=getQuerystring('opt', 'no option');
    var tex=getQuerystring('tex', 'no option');
    var QID=getQuerystring('QID', 'noQid');//if 11 dream
        
    var isOk="true";
    var errorMsg="";
    if(email=="")
    {
        errorMsg="Please provide email";
        isOk=false;
    }
    if(isOk)
    {
        if(IsValidEmail(email)=="0")
        {
            errorMsg="Invalid email";
            isOk=false;
        }
    }
    if(isOk)
    {
      window.location.href="../getSet.aspx?cmn=1&Qtxt="+Qtxt+"&name="+name+"&email="+email+"&opt="+choice+"&tex="+tex+"&QID="+QID;
     
    }
    else
    {
        alert(errorMsg);
        return isOk;
    }
}

function submitId()
{
    var name=document.getElementById("txtName").value;
    var email=document.getElementById("txtEmail").value;
    var choice=getQuerystring('opt', 'no option');
    var tex=getQuerystring('tex', 'no option');
    var pid=getQuerystring('pid', 'no pid');
    //var QID=getQuerystring('QID', 'noQid');//if 11 dream
        
    var isOk="true";
    var errorMsg="";
    if(email=="")
    {
        errorMsg="Please provide email";
        isOk=false;
    }
    if(isOk)
    {
        if(IsValidEmail(email)=="0")
        {
            errorMsg="Invalid email";
            isOk=false;
        }
    }
    if(isOk)
    {
    //if(QID=="noQid")//Questionaire
    //    {
            window.location.href="../getSet.aspx?pid="+pid+"&name="+name+"&email="+email+"&opt="+choice+"&tex="+tex;
    //    }
    // else if(QID=="11") //dream
    //    {
    //        window.location.href="../getSet.aspx?pid="+pid+"&name="+name+"&email="+email+"&opt="+choice+"&tex="+tex+"&QID=11";
   //     }   
    }
    else
    {
        alert(errorMsg);
        return isOk;
    }
}

function IsValidEmail(strControlName)
	{
		var rgeExp = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/ ;
		if (strControlName.search(rgeExp) < 0)
			{
				return "0" ;
			}
		else
		    {
		        return "1";
		    }
	}

function bodyLoad()
{
    //check is voted
    if(getQuerystring('v', 'notVoted')=="true")
    {
        if(getQuerystring('se', 'noSession')=="false")//session not exist
        {
            showPopUp();
        }
    }
    if(getQuerystring('succ', 'not')!="0" && getQuerystring('succ', 'not')!="not")
    {
        alert("Your response has been submitted.");
        if(getQuerystring('popwin', 'not')=="y")
        {
            win1();
        }
    }
    if(getQuerystring('succ', 'not')=="0")
    {
        alert("some error has occured");
    }
    
    MM_preloadImages('../images/dda_hover.jpg','../images/face_hover.jpg','../images/twitter_hover.jpg','../images/share_hover.jpg','../images/tube_hover.jpg','../images/flickr_hover.jpg','../images/bookmark_hover.jpg','../images/rti_hover.jpg');
}

function bodyLoadPop()
{
    //check is voted
    if(getQuerystring('v', 'notVoted')=="true")
    {
        if(getQuerystring('se', 'noSession')=="false")//session not exist
        {
            showPopUp();
        }
    }
    if(getQuerystring('succ', 'not')!="0" && getQuerystring('succ', 'not')!="not")
    {
        alert("Your response has been submitted.");
        
    }
    if(getQuerystring('succ', 'not')=="0")
    {
        alert("some error has occured");
    }
    
   
}


function bodyLoadCmn()
{
    //check is voted
    if(getQuerystring('v', 'notVoted')=="true")
    {
        if(getQuerystring('se', 'noSession')=="false")//session not exist
        {
            showPopUp();
        }
    }
    if(getQuerystring('succ', 'not')!="0" && getQuerystring('succ', 'not')!="not")
    {
        alert("Your response has been submitted.");
       
    }
    if(getQuerystring('succ', 'not')=="0")
    {
        alert("some error has occured");
    }
    
   
}

//function to return query string
function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

function showPopUp()//for login
{
   SetLayerPosition();

            var shadow = document.getElementById("shadow");
            var question = document.getElementById("divLogin");
     
            shadow.style.display = "block"; 
            question.style.display = "block";

            shadow = null;
            question = null;
}


function HideLayer() 
        {
            var shadow = document.getElementById("shadow");
            var question = document.getElementById("divLogin");
         
            shadow.style.display = "none"; 
            question.style.display = "none";

            shadow = null;
            question = null; 
            
            return false;
        }

       window.onresize = SetLayerPosition;
  function SetLayerPosition() 
        {
            var shadow = document.getElementById("shadow");
            var question = document.getElementById("divLogin");

            var bws = getBrowserHeight();
            shadow.style.width = bws.width + "px";
            shadow.style.height = bws.height + "px";
           // shadow.style.height = document.body.clientHeight + "px";

        question.style.left = parseInt((bws.width - 1024) / 2);
        question.style.top = 20;

            shadow = null;
            question = null;
        }
          

    function getBrowserHeight() 
        {
            var intH = 0;
            var intW = 0;
                       
            if(typeof window.innerWidth  == 'number' ) 
            {
                intH = window.innerHeight;
                intW = window.innerWidth;
            } 
            else
            { 
                if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
                {
                    intH = document.documentElement.clientHeight;
                    intW = document.documentElement.clientWidth;
                }
                else 
                {
                    if(document.body && (document.body.clientWidth || document.body.clientHeight)) 
                    {
                        intH = document.body.clientHeight;
                        intW = document.body.clientWidth;
                    }
                }
            }
            return { width: parseInt(intW), height: parseInt(intH) };
        }   
      
        
//Hide dream layer
/*
function hideLayerDream()
 {
     var shadow = document.getElementById("shadow");
     var question = document.getElementById("divDream");
         
     shadow.style.display = "none"; 
     question.style.display = "none";

     shadow = null;
     question = null; 
            
}

window.onresize = SetLayerPositionDream;
function SetLayerPositionDream() 
        {
            var shadow = document.getElementById("shadow");
            var question = document.getElementById("divDream");

            var bws = getBrowserHeight();
            shadow.style.width = bws.width + "px";
            //shadow.style.height = bws.height + "px";
            shadow.style.height = document.body.clientHeight + "px";

        question.style.left = parseInt((bws.width - 1024) / 2);
        question.style.top = 20;

            shadow = null;
            question = null;
        }
*/          

function submitForm(e)
{
    if(e.keyCode==13)
        submitId();
}

/*
    Added by: Shyam
    Dated: 8 Oct 09
    For Hover pop up
*/

function generateGraph()
{
if(getQuerystring('QIDs', 'No Result')!='No Result')
    {
        graph = new BAR_GRAPH("pBar");
        graph.values =getQuerystring('RIDs', 'No Result');
        graph.labels= getQuerystring('QIDs', 'No Result');
        document.write(graph.create());
        document.getElementById("headerDiv").style.display='';
    }
    else
    {
        document.getElementById("headerDiv").style.display='none';
    }
}
                    

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
    if (IE) 
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    else 
    {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX;
        tempY = e.pageY;
    }  
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}  
    //document.Show.MouseX.value = tempX;
   // document.Show.MouseY.value = tempY;
    return true;
}

function ShowPopupHover(hoveritem)
{
    hp = document.getElementById("hoverpopup");

    // Set position of hover-over popup
    hp.style.top = hoveritem.offsetTop + 18 + "px";
    hp.style.left = hoveritem.offsetLeft + 20 + "px";
    
    hp.style.top = tempY + 18 + "px";
    hp.style.left = tempX + 20 + "px";
    // Set popup to visible
    hp.style.visibility = "Visible";
}

function HidePopupHover()
{
    hp = document.getElementById("hoverpopup");
    hp.style.visibility = "Hidden";
}
///////Addition by Shyam (8 Oct) End here///////////




 
