//mySkillsmyFuture related common js functions
function PopupHelp(url)
{
    var helpWindow =window.open(url,'OverviewHelp','width=900,height=600,toolbar=1,status=1,menubar=1,scrollbars=1,statusbar=1,titlebar=yes,location=yes,resizable=yes');
    helpWindow.focus();
}

function popup(videourl, windowname, width, height)
{
    //if (! window.focus)
    //    return true;
    var href;
    var popWindow;
    if (typeof(videourl) == 'string')
       href=videourl;
    else
       href=videourl.href;
    if (window.showModalDialog) {
        //popWindow = window.open(href, '\'' + windowname + '\'', 'height='+width+',width='+width+',location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
        window.open(href,'newWindow','height='+ (height+20) +',width='+ (width+20)+',location=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
    }
    else
        popWindow = window.open(href, 'newWindow', 'width='+ (width+20) +',height='+ (height+20) +',resizable=1,scrollbars=no,toolbar=no,status=no,menubar=no,modal=yes');
    
    return false;
}

//Share link position
  function findShareThisPos()
            {
               var curleft = 0;
	    if (navigator.appName.indexOf('Microsoft') != -1)
	    {
	        var pageWid = pageWidth();  
			var leftoffset = 0; 
			if (pageWid > 960) 
			{ 	
				leftoffset = (pageWid-960) / 2; 	
				if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
	 				var ieversion=new Number(RegExp.$1);
					if (ieversion<=6) {
						curleft = curleft - leftoffset; 
					}					
					else if (ieversion==7) 
					{
						curleft = curleft - 10 - leftoffset; 
					}
				}
			}
			else 
			{
				if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
	 				var ieversion=new Number(RegExp.$1);
	 				if (ieversion<=6) {
						curleft = 200; 
					}
					else 
					{
						curleft = 190; 
					}
				}
			}				
		}
		return curleft; 
        }
function URLEncode(clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}
 

function OpenEmailWindow()
{
    // This is for passing additional parameter when in spanish mode. This way email this page can handle the spanish language
    var translang = readCookie('lang');   
    var loc = window.location;
    if ((loc.toString().toUpperCase().indexOf('?') > -1) && (translang == 'es')) {
        loc = loc + "&lang=" + translang;
    }
    else if ((translang == 'es')) {
        loc = loc + "?lang=" + translang;
    }
    //alert(loc);
    if(loc.toString().toUpperCase().indexOf('QAMYSKILLSMYFUTURE') > -1)
    {
      window.open('http://qa.careeronestop.local/EmailthisPage/COS_emailThisPage.aspx?url=' + URLEncode(loc),'EmailThisPage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=300,top=100,left=300');
     }
     else if(loc.toString().toUpperCase().indexOf('STAGEPREVIEW') > -1)
     {
         window.open('http://rdstage.careeronestop.org/EmailthisPage/COS_emailThisPage.aspx?url=' + URLEncode(loc), 'EmailThisPage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=300,top=100,left=300');
     }
     else {
         window.open('http://www.careeronestop.org/EmailthisPage/COS_emailThisPage.aspx?url=' + URLEncode(loc), 'EmailThisPage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=300,top=100,left=300');
     }

//    return false;
 }

 function OpenPDFEmailWindow(mode) {
     // This is for passing additional parameter when in spanish mode. This way email this page can handle the spanish language
      var translang = readCookie('lang');
      if (mode == "A") {
          var loc = window.location + "&Mode=A";
      }
      else {
          var loc = window.location + "&Mode=H";
      }     
    
    
     if ((loc.toString().toUpperCase().indexOf('?') > -1) && (translang == 'es')) {
         loc = loc  + "&lang=" + translang;
     }
     else if ((translang == 'es')) {
         loc = loc + "?lang=" + translang;
     }
     //alert(loc);
     if (loc.toString().toUpperCase().indexOf('QAMYSKILLSMYFUTURE') > -1) {
         window.open('http://qa.careeronestop.local/EmailthisPage/COS_emailThisPage.aspx?url=' + URLEncode(loc), 'EmailThisPage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=300,top=100,left=300');
     }
     else if (loc.toString().toUpperCase().indexOf('STAGEPREVIEW') > -1) {
     window.open('http://rdstage.careeronestop.org/EmailthisPage/COS_emailThisPage.aspx?url=' + URLEncode(loc), 'EmailThisPage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=300,top=100,left=300');
     }
     else {
         window.open('http://www.careeronestop.org/EmailthisPage/COS_emailThisPage.aspx?url=' + URLEncode(loc), 'EmailThisPage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=300,top=100,left=300');
     }

     //    return false;
 }
function OpenContactUs()
{
    var loc = window.location;
    if(loc.toString().toUpperCase().indexOf('QAMYSKILLSMYFUTURE') > -1)
    {
    window.open('http://qa.careeronestop.local/ContactUsPage/COS_ContactUs.aspx?previousUrl=' + loc,'contactuspage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=730,height=650,top=250,left=350');
    }
    else if(loc.toString().toUpperCase().indexOf('STAGEPREVIEW') > -1)
     {
     window.open('http://rdstage.careeronestop.org/ContactUsPage/COS_ContactUs.aspx?previousUrl=' + loc,'contactuspage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=730,height=650,top=250,left=350');
     }
     else
     {
     window.open('http://www.careeronestop.org/ContactUsPage/COS_ContactUs.aspx?previousUrl=' + loc,'contactuspage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=730,height=650,top=250,left=350');
     }
  //  return false;
}
function OpenPrint()
{
window.print();
 return false;
}

function URLEncode(clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function SiteSearchKeyUp(objTextElement, txtSiteSearch) {
    if (txtSiteSearch.indexOf('<') >= 0) {
        objTextElement.value = txtSiteSearch.replace(/</g, '')
    }
    if (txtSiteSearch.indexOf('>') >= 0) {
        objTextElement.value = txtSiteSearch.replace(/>/g, '')
    }
}
function SiteSearchMouseOut(objTextElement, txtSiteSearch) {
    if (txtSiteSearch.indexOf('<') >= 0) {
        objTextElement = txtSiteSearch.replace(/</g, '')
    }
    if (txtSiteSearch.indexOf('>') >= 0) {
        objTextElement = txtSiteSearch.replace(/>/g, '')
    }
}
function PopupVideo(videourl, videoName, width, height)
{
      window.open(videourl, 'Training','width='+width +',height='+height+',scrollbars=no,toolbar=no,status=no,menubar=no,modal=yes');
      //return false;
  }
  function readCookie(name) {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) == ' ') c = c.substring(1, c.length);
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
      }
      return null;
  }

  function IndustryCheckBoxListSelect(cbControl,id) {
      var chkBoxList = document.getElementById(cbControl);

      var chkBoxCount = chkBoxList.getElementsByTagName("input");


      if (id == 0) {
          if (chkBoxCount[0].checked) {
              state = true;
          }
          else {
              state = false;
          }
          for (var i = 0; i < chkBoxCount.length; i++) {

              chkBoxCount[i].checked = state;

          }
      }
      else {

          var TotalBoxes = 0;
          var TotalOn = 0;
          for (var i = 0; i < chkBoxCount.length; i++) {
              var e = chkBoxCount[i];
              if ((e.name != 'ctl00$ContentPlaceHolder1$chklstIndustries$0')  && (e.type == 'checkbox')) {
                  TotalBoxes++;
                  if (e.checked) {
                      TotalOn++;
                  }
              }
              if (TotalBoxes == TotalOn) {
                  chkBoxCount[0].checked = true;
              }
              else {
                  chkBoxCount[0].checked = false;
              }

          }
 
         /* if (chkBoxCount[0].checked) {
              chkBoxCount[0].checked = false;
          }*/


      }
        return false;
    }

    function SizeCheckBoxListSelect(cbControl, id) {
        var chkBoxList = document.getElementById(cbControl);

        var chkBoxCount = chkBoxList.getElementsByTagName("input");


        if (id == 0) {
            if (chkBoxCount[0].checked) {
                state = true;
            }
            else {
                state = false;
            }
            for (var i = 0; i < chkBoxCount.length; i++) {

                chkBoxCount[i].checked = state;

            }
        }
        else {

            var TotalBoxes = 0;
            var TotalOn = 0;
            for (var i = 0; i < chkBoxCount.length; i++) {
                var e = chkBoxCount[i];
                if ((e.name != 'ctl00$ContentPlaceHolder1$chklstSize$0') && (e.type == 'checkbox')) {
                    TotalBoxes++;
                    if (e.checked) {
                        TotalOn++;
                    }
                }
                if (TotalBoxes == TotalOn) {
                    chkBoxCount[0].checked = true;
                }
                else {
                    chkBoxCount[0].checked = false;
                }

            }
            /* if (chkBoxCount[0].checked) {
            chkBoxCount[0].checked = false;
            }*/


        }
        return false;
    }

