var getCampaign = 0;

function copyText(id) {

	selectText(id);
	
	var link = document.getElementById(id);
	window.clipboardData.setData('Text', link.value);
	
	//get the clipboard data
	//var link = window.clipboardData.getData('Text');
	
	//clear clipboard data
	//window.clipboardData.clearData();
}

function selectText(id) {
	document.getElementById(id).focus();
    document.getElementById(id).select();
}

function change_iframe(url) {
	ifrm.location=url;
}

function set_dates(f)
{
    dates = f.pay_period.value.split(' -- ');
    sdate = dates[0].split('-');
    edate = dates[1].split('-');
    f.month1[sdate[1]-1].selected=true;
    f.day1[sdate[2]-1].selected=true;
    f.year1[-(f.year1[0].value-sdate[0])].selected=true;
    f.month2[edate[1]-1].selected=true;
    f.day2[edate[2]-1].selected=true;
    f.year2[-(f.year1[0].value-edate[0])].selected=true;
}

function filterCategory(obj) {
	
	document.location.href='index.php?a=rewards&group=&categories='+obj.value;
}

function deleteAdmin(adminId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_create&group=&adminID='+adminId+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_create&group=&adminID='+adminId+'&cancel=1';
	}
}

function deleteCampaign(campaignId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=campaign&group=&campaignId='+campaignId+'&option=delete';
	}
	else {
		window.location.href='index.php?a=campaign&group=&campaignId='+campaignId+'&option=cancel';
	}
}

function deleteWMCampaign(campaignId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=wm_referrals&group=wm_referrals&campaignId='+campaignId+'&option=delete';
	}
	else {
		window.location.href='index.php?a=wm_referrals&group=wm_referrals&campaignId='+campaignId+'&option=cancel';
	}
}

function deleteNews(newsId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_news&newsID='+newsId+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_news';
	}
}

function deleteBlogs(blogId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_blogs&blogID='+blogId+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_blogs';
	}
}

function deleteFreeContent(imageId, galleryId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_free_content&ImageID='+imageId+'&galleryID='+galleryId+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_free_content';
	}
}

function deleteReward(id) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_rewards&id='+id+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_rewards';
	}
}

function deleteTubeContent(tubeId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_tube_content&id='+tubeId+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_tube_content';
	}
}

function deletebannerContent(bannerId) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_banners&id='+bannerId+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_banners';
	}
}

function deletePOTDContent(fileName) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_potd&file='+fileName+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_potd';
	}
}

function deleteMOTDContent(fileName) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_motd&file='+fileName+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_motd';
	}
}

function deleteFHG(fhgID) {
	
	var answer = confirm("Are you sure?");
	if(answer) {
		window.location.href='index.php?a=admin_hosted_galleries&fhgID='+fhgID+'&delete=1';
	}
	else {
		window.location.href='index.php?a=admin_hosted_galleries';
	}
}

function popupWindow(page, windowWidth, windowHeight, windowOptions) {
	
	var iMyWidth;
	var iMyHeight;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (windowWidth/2 + 10);
	
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (windowHeight/2 + 50);
	
	//Open the window.
	var win2 = window.open(page,"Window","width=" + windowWidth + ",height=" + windowHeight + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + "," + windowOptions);
	win2.focus();
}

function create_form()
{
    mypara=document.getElementById("para_payoneer");
    myform=document.createElement("form");
    myform.setAttribute("id","formID");
    myform.setAttribute("action","");
    myform.setAttribute("method","post");
    myform.setAttribute("target","_blank");
    myinput = document.createElement("input");
    myinput.setAttribute("name","apply_payoneer");
    myinput.setAttribute("value","Apply for Payoneer");
    myform.appendChild(myinput);
    mypara.appendChild(myform);
    myform.submit();
}

function changeLinkCodeTour(siteID, wmID, dropdownVal, program, campaign, console) {
	getCampaign = campaign;
	
	if(campaign == '') {
		campaign = 0;
	}
	var val = 'http://hustlercash.com/hit/'+siteID+'/'+program+'/'+wmID+'/'+dropdownVal+'/'+campaign+'/'+console;
	document.getElementById('paysites_tour_link_'+siteID).value=val;
	document.getElementById('paysites_tour_link2_'+siteID).href=val;
}

function changeLinkCodeWMCampaign(wmID, dropdownVal) {
	var val = 'http://hustlercash.com/ref.php?w='+wmID+'&c='+dropdownVal;
	document.getElementById('wmref_tour_link').value=val;
	document.getElementById('wmref_tour_link_view').href=val;
}

function changeLinkCodeLiveCampaign(siteID, wmID, dropdownVal) {
	var val = 'http://hustlercash.com/hit/'+siteID+'/2/'+wmID+'/0/'+dropdownVal+'/1';
	document.getElementById('live_tour_link_'+siteID).value=val;
	document.getElementById('liveView_'+siteID).href=val;
}

function setSelectedIndex(s, i) {
	s.options[i-1].selected = true;
	return;
}

function setSelectedIndex2(frm, select, text) {
	var s = document["form1"][select];
	for(i=0; i<=s.options.length-1;i++) {
		if(s[i].text == text) {
			s.options[i].selected = true;
		}
	}
}
