
// JavaScript Tools JS file For Cinnergen.com

// Start Of Functions Below -----------------------------------------------------------------

// Start Of Function For Visitor Tracking For Murchant Processor

var str = document.domain;
var domain = str.replace(/www\./i, "");

var refer = 'Referred-From-Shopping-Cart';
if (document.referrer && document.referrer != '') { refer = document.referrer; }

var dvalue = escape(refer) // escape dvalue values

function createCookie(name, value, days) { // create cookie function
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/" + "; domain=" + domain;
}

function readCookie(name) { // read cookie function
var ca = document.cookie.split(';');
var nameEQ = name + "=";
for(var i=0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return "";
}

function cookiTest() { // test for cookie refer set
var acookie = readCookie("trak");
if (acookie.length == 0) {
createCookie("trak", dvalue, 5); // set cookie for 5 days
// alert("Cookie Set " + dvalue);
} else {
// alert("Cookie All Ready Set " + acookie);
}
}

window.onload = cookiTest;

// End Of Function For Visitor Tracking For Murchant Processor

// Start check flash player state for playing
function getUpdate(typ,pr1) {
var id = document.getElementById(typ);
if(typ == "state") {
myTyp = typ;
myVal = Math.round(pr1);
}
};
// End check flash player state for playing

// Start javascript send call to the flash player
function sendEvent(typ,prm) {
thisMovie("FlashPlayerDoc").sendEvent(typ,prm);
};
// End javascript send call to the flash player

// Start javascript handler for the flash player
function thisMovie(movieName) {
if(navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
};
// End javascript handler for the flash player


// Start PopUp IFrame Window Functions -----------------------------------------------------------------

// Start PopUp IFrame Window
function popfuction(iframepage,winset) {

if (winset == 1) {  // WinSet 1 = PopUp Submission Offers
sendEvent('stop'); // Flash player stop / reset
var IFWidth = 320;      // popup window Two size
var IFHigh = 260;
var myLEFTadj = 0;  // popup window Two offset adjust > OK To Use Negtive Values
var myTOPadj = 0;
}

if (winset == 2) {  // WinSet 2 = Video Testimonials
var IFWidth = 320;      // popup window Two size
var IFHigh = 260;
var myLEFTadj = 80;  // popup window Two offset adjust > OK To Use Negtive Values
var myTOPadj = 0;
}

var show = 'visible';

function getObj(name) {  // Function To Get HTML Object And Style
if (document.getElementById) {
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all) {
this.obj = document.all[name];
this.style = document.all[name].style;
}
}

var x = new getObj('popup'); // Must Be The ID/NAME Of The Iframe

var myWidth = 0, myHeight = 0;  //  Start Of determine ViewPort Width And Height
if( typeof( window.innerWidth ) == 'number' ) {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
  myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  //IE 4 compatible
  myWidth = document.body.clientWidth;
  myHeight = document.body.clientHeight;
}
// window.alert( 'Width = ' + myWidth );
// window.alert( 'Height = ' + myHeight );

var scrOfX = 0, scrOfY = 0;  //  Start Of determine ViewPort ScrollWidth And ScrollHeight
if( typeof( window.pageYOffset ) == 'number' ) {
  //Netscape compliant
  scrOfY = window.pageYOffset;
  scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
  //DOM compliant
  scrOfY = document.body.scrollTop;
  scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
  //IE6 standards compliant mode
  scrOfY = document.documentElement.scrollTop;
  scrOfX = document.documentElement.scrollLeft;
}
// window.alert( 'ScrolWidth = ' + scrOfX );
// window.alert( 'ScrolHeight = ' + scrOfY );

var LeftEdg = (myWidth - IFWidth) / 2;
var TopEdg = (myHeight - IFHigh) / 2;

var LeftEdg = LeftEdg + scrOfX;
var TopEdg = TopEdg + scrOfY;

var IFLeft = LeftEdg + myLEFTadj;
var IFTop = TopEdg + myTOPadj;

frames[0].location.href = iframepage;  // Note If More Than 1 IFrame Change Number To Target Frame
x.style.top = IFTop+'px';
x.style.left = IFLeft+'px';
x.style.width = IFWidth+'px';
x.style.height = IFHigh+'px';
x.style.visibility = show;

} // End of PopUp IFrame Window function


// Start of Close PopUp IFrame Window function
function HideIFrame(){

var page = 'blank.html';      // popup IFrame preload page

function getObj(name) {  // Function To Get HTML Object And Style
if (document.getElementById) {
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all) {
this.obj = document.all[name];
this.style = document.all[name].style;
}
}

var y = new getObj('popup'); // Must Be The ID/NAME Of The Iframe

var hide = 'hidden';

var IFClose = 1;

//clearInterval(StopScroller);

y.style.visibility = hide;
y.style.width = IFClose+'px';
y.style.height = IFClose+'px';
frames[0].location.href = page;  // Note If More Than 1 IFrame Change Number To Target Frame
} // End of Close PopUp IFrame Window function


