(function() {
	var oScript = document.createElement('script'); oScript.type = 'text/javascript'; oScript.async = true;
	oScript.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(oScript, s);
	oScript.onreadystatechange = function() {
		if ((this.readyState == 'complete') || (this.readyState == 'loaded')) {
			jQuery(document).ready(function() {
				addSlideEvent();
				socialShare();
			});
		}
	}
	oScript.onload = function() {
		
		jQuery(document).ready(function() {
			addSlideEvent();
			socialShare();
		});
	};
})();


function socialShare() {
	var shareEls = jQuery('#content-thankyou .social a');
	
	social.setOptions({
		url : 'http://www.purina.com.au/fancyfeast',
		title : "I've just entered the $20,000 KITCHEN MAKEOVER draw with Fancy Feast",
		description : 'You can enter too if you purchase 10 PURINA FANCY FEAST cans in a single transaction then enter the draw to WIN one of five $20,000 kitchen makeover prizes. Entries close 5pm AEDST 20/12/2011. *',
		twitterMessage : "I've entered to WIN A $20,000 KITCHEN MAKEOVER with Fancy Feast. Buy 10 PURINA FANCY FEAST cans to go into the draw: http://www.purina.com.au/winakitchen"
	});
	
	if (shareEls.length > 0) {
		shareEls.click(function(e) {
			e.preventDefault();
			var network = this.hash.substr(1),
				func = social[network];
			if (!(network in social) || !jQuery.isFunction(func)) {
				alert('Invalid social network.');
				return;
			}
			func(jQuery(this));
		});
	}
}


function addSlideEvent()
{ 
	
	jQuery("#v_slideout").click(function(e) {
	    e.preventDefault();
	    jQuery("#vertical_slide").slideUp("slow")
	    jQuery("#buttonDiscover").show();    
	    jQuery("#buttonHide").hide();
	});
	
	
	jQuery("#v_slidein").click(function(e) {
	    e.preventDefault();
	    jQuery("#vertical_slide").slideDown("slow");
	    jQuery("#buttonDiscover").hide();    
	    jQuery("#buttonHide").show();
	
	});

}

function adjustIFrameSize(iframeHeightNumber) {
    var iframeId = jQuery('#survey-winakitchen');
    
    if (iframeId.length > 0) {
    	iframeId.attr('height', parseInt(iframeHeightNumber) + 30);
    }
}

function getURLParam(strParamName) {
	var strReturn = "";
	var strHref = window.location.href;
  
  	if ( strHref.indexOf("?") > -1 ) {
    	var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    	var aQueryString = strQueryString.split("&");
    	
    	for ( var iParam = 0; iParam < aQueryString.length; iParam++ ) {
      		if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ) {
        		var aParam = aQueryString[iParam].split("=");
        		strReturn = aParam[1];
        		break;
      		}
    	}
  	}
	
	return unescape(strReturn);
}

/*function adjustIFrameSize() {
	parent.parent.adjustIFrameSize(getURLParam("height"));
}*/
