﻿// JScript File

// add event to object
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function loadNewscast(playMode)
{
    document.getElementById("newscast").innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="453" height="210" id="newscast" align="left">'
	+'<param name="allowScriptAccess" value="sameDomain" />'
	+'<param name="movie" value="includes/media/newscast/newscast.swf" />'
	+'<param name="quality" value="high" />'
	+'<param name="loop" value="false" />'
	+'<param name="wmode" value="transparent" />'
	+'<param name="bgcolor" value="#354251" />'
	+'<param name="flashvars" value="playMode=' + playMode + '" />'
	+'<embed src="includes/media/newscast/newscast.swf" flashvars="playMode='+ playMode + '" quality="high" loop="false" wmode="transparent" bgcolor="#354251" width="453" height="210" name="newscast" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" />'
	+'</object>';
}

// Cookie functions
function getexpirydate( nodays){
    var UTCstring;
    Today = new Date();
    nomilli=Date.parse(Today);
    Today.setTime(nomilli+nodays*24*60*60*1000);
    UTCstring = Today.toUTCString();
    return UTCstring;
}
function getcookie(cookiename) {
    var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
    if (index1==-1 || cookiename=="") return ""; 
    var index2=cookiestring.indexOf(';',index1);
    if (index2==-1) index2=cookiestring.length; 
    return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,days){
    cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(days);
    document.cookie=cookiestring;
    if(!getcookie(name)){
        return false;
    } else {
        return true;
    }
}

//load flash file
function loadFlash(aDiv, aMovie, aWidth, aHeight)
{
	document.getElementById(aDiv).innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + aWidth + '" height="' + aHeight + '" id="' + aDiv + '" align="middle">'
	+'<param name="allowScriptAccess" value="sameDomain" />'
	+'<param name="movie" value="' + aMovie + '" />'
	+'<param name="quality" value="high" />'
	+'<param name="loop" value="false" />'
	+'<param name="wmode" value="transparent" />'
	+'<param name="bgcolor" value="#FFFFFF" />'
	+'<embed src="' + aMovie + '"  quality="high" loop="false" wmode="transparent" bgcolor="#FFFFFF" width="' + aWidth + '" height="' + aHeight + '" name="' + aDiv + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" />'
	+'</object>';
}



// returns querystring value

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return unescape(pair[1]);
    }
  } 
  return "";
}

//function will take a button and change value to processing
function disableButton(aButton){
	if(document.getElementById(aButton))
	    document.getElementById(aButton).value="Processing...";
}


//functions to get current windows width and height
function getWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth  ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getHeight(){
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}
function ResetPaging(PagingCtl)
{
    __doPostBack(PagingCtl);
}
function open_dialogbox(path,width,height,resize,scroll,status,samewindow)
{	
	var w = 480, h = 340;
	if(!width)
		width="700";
	if(!height)
		height="500";
	if(!resize)
		resize="no";
	if(!scroll)
		scroll="no";
	if(!samewindow)
		samewindow="objwnd";
	if(!status)
		status="no";
	
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	objwnd=window.open(path,samewindow,"munubar=no,titlebar=no,status="+status+",resizable="+resize+",scrollbars="+scroll+",width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd.focus();
}
function viewYourProfile(url) {
    //var win;
    //win=dhtmlmodal.open("ibox", "iframe", url, "WomenCertified.com Consumer Website", "width=980px,height=400px,resize=1,scrolling=0,center=1");    
    open_dialogbox(url,'710','600','yes','yes','yes','1');
    //win=dhtmlmodal.open("ibox", "ajax", url, "WomenCertified.com Consumer Website", "width=740px,height=320px,resize=1,scrolling=0,center=1");    
}