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 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 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();
}