
// ***** Popup Windows ************************************************************************************** //

/* START JS Browser detect code */
var bow="n";
var bow1="n";

bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

if (bName == "Netscape" && bVer >= 3)
{
	bow = "ok";
	bow1 = "ok";
}
else if (bName == "Microsoft Internet Explorer" && bVer > 3)
{
	bow = "ok";
	bow1="ok";
}
else if (bName == "Microsoft Internet Explorer" && bVer >=2)
{
	bow = "ok";
}

var IS_AOL=0;

if (navigator.userAgent)
{
	if (navigator.userAgent.indexOf("AOL") >=0)
	{
		IS_AOL=1;
		bow1="n";
	}
}
else
{
	bow="n"
	bow1="n";
}
/* END JS Browser detect code */

/* Popup Sized Window */
function openWinSized(f,t,w,h){
	return openWindow(f, t, 'no', 'no', 'yes', 'no', w, h, 'no', 'no', 'no');
}
/* Popup used in video 16:9 */
function openPhotoWin169(f,t){
	return openWindow(f, t, 'no', 'no', 'no', 'no', 600, 320, 'no', 'no', 'no');
}
/* Popup Sized Window */
function openWinSized(f,t,w,h,s,r){
	return openWindow(f, t, 'no', 'no', s, r, w, h, 'no', 'no', 'no');
}

/* general utility function that accepts parameters for url of filename (f),
target Window (t), 
menubar (m - yes/no), location (l - yes/no), 
scrollbars (s - yes/no), resizeable (r - yes/no), 
window width (w), window height (h). 
Default values are laid out in the function.
*/
function openWindow(f, t, m, l, s, r, w, h, st, tool, d)
{
	var fn_filename = "";
	var fn_target = "_blank";
	var fn_menubar = "yes";
	var fn_location = "yes";
	var fn_scrollbars = "yes";
	var fn_resizable = "yes";
	var fn_width = "600";
	var fn_height = "400";
	var fn_status = "yes";
	var fn_toolbar = "yes";
	var fn_directories = "yes";
	
	if (arguments.length > 0)
	{
		if (f != "" || f != null) fn_filename = f;
		if (t != "" || t != null) fn_target = t;
		if (m == "no") fn_menubar = m;
		if (l == "no") fn_location = l;
		if (s == "no") fn_scrollbars = s;
		if (r == "no") fn_resizable = r;
		if (w > 0) fn_width = w;
		if (h > 0) fn_height = h;
		if (st == "no") fn_status = st;
		if (tool == "no") fn_toolbar = tool;
		if (d == "no") fn_directories = d;
	}
	
	self.name="MainWin";
	
  if (bow!="ok") return (true);
	
	argumentString = 'menubar='+fn_menubar+',location='+fn_location+',scrollbars='+fn_scrollbars+',resizable='+fn_resizable+',width='+fn_width+',height='+fn_height+',status='+fn_status+',toolbar='+fn_toolbar+',directories='+fn_directories;
	
	remote =  window.open(fn_filename,fn_target,argumentString);

    if (remote == null) return true;

    if (bow1 =="ok") window.setTimeout('remote.focus()',1000);
	return (false);
}




// ***** TRACKING FUNCTIONS ************************************************************************************** //

// function to track SiteCatalyst Lead links
function trackSCLead(productID, leadType, leadEvent) {
  var s=s_gi(s_account);
  
  if (productID != "") {
    s.products = ";" + productID;
  }
  
  s.eVar17=leadType;
  
  if (leadEvent == 0) {
    s.events="event9";
    s.linkTrackEvents="event9"
  } else {
    s.events="event10";
    s.linkTrackEvents="event10"
  }
  
  s.linkTrackVars="eVar17,products,events"
  s.tl(this,'o','Lead');
}

function trackSCDownload(downloadName) {
  var s=s_gi(s_account);
  s.linkTrackVars='eVar18,events';
  s.linkTrackEvents='event11';
  s.events='event11';
  s.eVar18=downloadName;
  s.tl(this,'d',downloadName);
}

function trackSCEvent(eventID) {
  var s=s_gi(s_account);
  s.events=eventID
  s.linkTrackVars="events"
  s.linkTrackEvents=eventID
  s.tl(true,'o','Login');
}

function trackSCPartnerRefer(partnerName) {
  var s=s_gi(s_account);
  s.events="event13"
  s.eVar20=partnerName;
  s.linkTrackVars="eVar20,events"
  s.linkTrackEvents="event13"
  s.tl(true,'o','Partner Referral');
}


// ***** EYE MAG ************************************************************************************** //

function openEyemag(projectnr, siteid, pagenumber) {

  var fileurl = 'http://www.eyemag.se/core/main.php?PROJECTNR=' + projectnr + '&SITEID=' + siteid + '&OPENPAGE=' + pagenumber;
  
  if (document.all) 
    var xMax = screen.width, yMax = screen.height-16; 
  else { 
    if (document.layers) 
      var xMax = window.outerWidth, yMax = window.outerHeight; 
    else var xMax = 1000, yMax=800; 
  }
  
  var w = xMax-10;
  var h = yMax-12;
  var pop = window.open(fileurl,'Eyemag','width='+w+',height='+h+', screenX=0,screenY=0,top=0,left=0,menubar=0,toolbar=0,status=no,resizable=no');
  
} 



// ***** VALIDATION FUNCTIONS ************************************************************************************** //

// function to validate email addresses
function validateEmail(theEmail) {
  
  var regExp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
  
  if ( !( regExp.test( theEmail ) ) ) {
    return false;
  } else {
    return true;
  }
  
}


// function to clear the keyword field on search forms
function clearKeywordValue(keywordField)  {
  if (keywordField.value == "Enter a Keyword/s" || keywordField.value == "Search using keywords") {
    keywordField.value = "";
  }
}


function closeDialog(objectUUID) {
  $('#dialogWindow'+objectUUID).dialog('close');
}




// ***** DOCUMENT READY FUNCTIONS ************************************************************************************** //


var $loading = $('<img src="/iss/fms/graphics/icons/loading.gif" alt="loading" class="loading">');


$(document).ready(function() {
  
  $("#socialMediaTabs").tabs({ cache: true });
  
  $("#tabs1").tabs({ cache: true });
  
});
