﻿function getObj(o) {
  if (document.getElementById) {
    return document.getElementById(o);
  }
  else if (document.all) {
    return document.all(o);
  }
  else if (document.layers) {
    return document.layers(o);
  }
}
function hide(o)
{
    getObj(o).style.display='none';
    getObj(o).style.visibility='hidden';
}
function display(o)
{
    getObj(o).style.display='';
    getObj(o).style.visibility='visible';
}

function Go(url)
{
    window.location = url;
}

function confirmDelete(item) 
{
    return confirm('Are you sure you want to delete this ' + item + '?');
}

function Print(path) 
{
	openWindow(path + 'resources/utilities/print.aspx', 680, 620, 'yes');
}

function openWindow(loc,wdt,hgt,scroll, resizable) 
{	
	window.open(loc, 'win', 'height=' + hgt + ',width=' + wdt + ',top=120,left=100' + ',toolbar=yes,scrollbars=' + scroll + ',resizable=' + resizable);
}

function pageWidth() 
{
    return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
}

function pageHeight() 
{
    return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}

function posLeft()
{
    return typeof window.pageXOffset != "undefined" ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft:document.body.scrollLeft ? document.body.scrollLeft : 0;
}

function posTop()
{
    return typeof window.pageYOffset != "undefined" ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

function posRight()
{
    return posLeft()+pageWidth();
}

function posBottom()
{
    return posTop()+pageHeight();
}

function DisableEnter(field, event, path) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		Go(path + 'modules/search/?q=' + field.value);
		return false;
	} 
	else
	return true;
}

function CheckBoxChange(cb) 
{

	var frm = cb.form, i = 0;
	
	while (i < frm.length) {
	
		if (frm[i].type == 'checkbox') {
		
			frm[i].checked = cb.checked;
		
		}
		
		i++;

	}

}
function Bookmark(url, title)
{
    if (window.external) {
        window.external.AddFavorite(url,title);
    } else { 
        alert("Sorry! Your browser doesn't support this function.");
    }
}

function fixit(str) {

    str = str.replace(/\'/g, "&#39;");
    str = str.replace(/\"/g, "&#34;");

    return str;

}

function Back(steps) {
    window.history.go(steps);
}

function ShowVideo(_player, _url, _title, _description, _path) {
    
    var img = _path + 'resources/images/player-bg.gif';
    var obj = {file:_url,title:_title,description:_description,image:img,autostart:true};
    getObj(_player).sendEvent("LOAD",obj);
    getObj(_player).sendEvent("PLAY",true);
    
}

function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

function forceSIFR(path) {   
    if(typeof sIFR == 'function'){
        sIFR.replaceElement('h2#title', path + 'resources/flash/VerlagBold.swf', '#008fd5', null, null, null, 0, 0, 0, 0, null, null, 'transparent');
        sIFR.replaceElement('h3.title', path + 'resources/flash/VerlagBook.swf', '#6d6f71', null, null, null, 0, 0, 0, 0, null, null, 'transparent');
        sIFR.replaceElement('h3', path + 'resources/flash/VerlagBook.swf', '#008fd5', null, null, null, 0, 0, 0, 0, null, null, 'transparent');
        sIFR.replaceElement('h4', path + 'resources/flash/VerlagBook.swf', '#008fd5', null, null, null, 0, 0, 0, 0, null, null, 'transparent');
    };
}

function LogView(path, playlist_id, leads_id) {

    c.ajax.invoke(path + 'modules/insights/playlist_download.aspx?playlist_id=' + playlist_id + '&leads_id=' + leads_id);

}
